是这样的,我的Activity中左侧是RelativeLayout包裹的listview,这个RelativeLayout的宽度是360dp,右侧是mapview。RelativeLayout是隐藏的,只有poi搜索出数据设置到listview后,才显示,这时候mapview向右侧移动,会闪黑屏,这个问题怎么解决呢?
时间: 2024-03-29 09:35:04 浏览: 19
这个问题可能与您的布局和视图层级有关。在您显示RelativeLayout并移动mapview时,可能会导致视图重叠或者不正确的绘制顺序,从而导致黑屏闪烁。
您可以尝试一些方法来解决这个问题:
1. 确保RelativeLayout和mapview的层级正确,RelativeLayout应该在mapview的下方。
2. 尝试使用动画来移动mapview,而不是直接更改其位置。这样可以让视图更流畅地移动,减少闪烁的可能性。
3. 如果您使用了透明度或者遮罩层来控制RelativeLayout的显示,可以尝试使用alpha动画来代替直接更改透明度或者遮罩层。
4. 如果您的应用在低端设备上出现了闪烁问题,可以尝试优化您的代码和布局,减少不必要的计算和绘制操作。
如果以上方法仍然不能解决您的问题,建议您提供更多详细信息和代码,让我更好地了解您的情况,并为您提供更具体的解决方案。
相关问题
但是这个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` 的空间。
我说错了,不是listview隐藏 是RelativeLayout隐藏
那么你可以在RelativeLayout隐藏时,手动设置mapview的左边距为0,这样可以保证mapview填充整个父容器,不会出现黑屏的情况。具体代码如下:
```
relativeLayout.setVisibility(View.GONE);
// 将mapview的左边距设置为0
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mapView.getLayoutParams();
params.leftMargin = 0;
mapView.setLayoutParams(params);
```
你需要将上述代码放到隐藏RelativeLayout的地方,这样就可以保证在RelativeLayout隐藏后,mapview会自动填充整个父容器,不会出现黑屏的情况。