简体   繁体   English

更改可见性后,Android调整MapView的大小

[英]Android Resize MapView after Visibility change

I've got an activity with the following layout: 我有一个具有以下布局的活动:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <com.google.android.maps.MapView
        android:id="@+id/map"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
    <LinearLayout
        android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:padding="5dp" >
        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:textColor="#FFF"
            android:padding="5dp" />
    </LinearLayout>
</LinearLayout>

I want to be able to hide/show the seperate LinearLayout with id 'view' and then let the MapView resize according to the space left. 我希望能够隐藏/显示ID为“ view”的单独LinearLayout,然后让MapView根据剩余空间调整大小。 When I try this the seperate LinearLayout is never shown. 当我尝试此操作时,永远不会显示单独的LinearLayout。 I'm not sure what is going on! 我不确定发生了什么! Is the LinearLayout forever hidden? 永远不会隐藏LinearLayout吗? is it behind the Mapview? 它在Mapview后面吗?

private void showMessage() {
    LinearLayout layout = (LinearLayout) findViewById(R.id.view);
    layout.setVisibility(View.VISIBLE);
}

private void hideMessage() {
    LinearLayout layout = (LinearLayout) findViewById(R.id.view);
    layout.setVisibility(View.GONE);
}

问题似乎可以通过更改XML布局文件中的初始化顺序来解决,并且在以后的Android版本中可能不会发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 显示android后如何在自定义对话框中更改视图的可见性 - How to change visibility of a view in custom dialog after showing it android 如何在Android Studio中将GONE可见性更改为VISIBLE可见性 - how to change a GONE visibility to VISIBLE visibility in android studio Android对话框,更改小部件可见性 - Android Dialog box, change widget visibility Android / java-更改Runnable类中的按钮可见性 - Android/java - Change button visibility in a Runnable class 在sdk android的基础上改变方法的可见性 - change visibility of method on the basis of sdk android 如何更改android中mapview上的drawable的大小? - how do I change the size of a drawable that is on mapview in android? Android MapView,如何在按钮按下时更改位置/标记 - Android MapView, how to change location/Marker on button press 在Android Google Maps中使用MapView执行任何操作后,不会加载地图图块 - Map Tiles are not loaded after doing anything with the MapView in Android Google Maps ImageView在将可见性从变为可见后不显示图像 - ImageView Not showing image after change visibility from gone to visible 更改过渡侦听器事件上共享元素过渡的可见性 - android - Change the visibility of shared element transition on transition listener events - android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM