protected RelativeLayout mPoiListContainer; 怎么使得这个mPoiListContainer隐藏?
时间: 2024-03-27 11:36:58 浏览: 13
您可以使用如下代码将mPoiListContainer隐藏:
```
mPoiListContainer.setVisibility(View.GONE);
```
这会将mPoiListContainer设置为不可见,并且不占用布局空间。如果您想要将其设置为占用布局空间但是不可见,可以将`View.GONE`替换为`View.INVISIBLE`。
相关问题
RelativeLayout定位,当一个控件被隐藏后怎样定位
当一个控件被隐藏后,RelativeLayout会自动调整其它控件的位置,以填补被隐藏控件的空缺。如果你想要相对于被隐藏控件的位置来定位另一个控件,可以使用android:layout_alignTop、android:layout_alignBottom、android:layout_alignLeft或android:layout_alignRight等属性来指定相对于被隐藏控件的对齐方式。如果你想要在被隐藏控件的位置上留有空白,可以使用android:layout_marginTop、android:layout_marginBottom、android:layout_marginLeft或android:layout_marginRight等属性来设置相应的边距值。
但是这个RelativeLayout包裹的listview还是在左侧显示哈
对不起,我的回答有误。根据你的描述,实际上是想要在 `MapView` 上方覆盖一个 `RelativeLayout`,并在其中显示 `ListView`,对吗?那么可以使用 `android:layout_above` 属性将 `RelativeLayout` 放置在 `MapView` 上方,并使用 `android:layout_alignParentLeft="true"` 和 `android:layout_alignParentRight="true"` 属性将 `RelativeLayout` 左右两侧与父容器对齐,避免 `RelativeLayout` 在左侧显示。具体代码如下所示:
```
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/poi_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_list_circular"
android:visibility="gone"
android:layout_above="@id/bmapView">
<ListView
android:id="@+id/poi_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hardwareAccelerated="true"
android:scrollbars="none" />
</RelativeLayout>
<com.baidu.mapapi.map.MapView
android:id="@+id/bmapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:hardwareAccelerated="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
```
这样可以将 `RelativeLayout` 放在 `MapView` 的上方,不会占用 `MapView` 的空间。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)