【问题标题】:Android Resize MapView after Visibility change可见性更改后Android Resize MapView
【发布时间】:2010-08-25 14:20:19
【问题描述】:

我有一个具有以下布局的活动:

<?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>

我希望能够隐藏/显示带有 id 'view' 的单独 LinearLayout,然后让 MapView 根据剩余空间调整大小。当我尝试这个时,永远不会显示单独的 LinearLayout。我不确定发生了什么事! LinearLayout 是否永远隐藏?它在 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);
}

【问题讨论】:

  • 我也试过调用主LinearLayout的requestLayout()方法,没有结果..
  • 奇怪的是,如果我将 ID 为“view”的 LinearLayout 移动到 MapView 上方,它似乎可以工作。 MapView 下面似乎不能这样工作?这是一个错误吗?人们可以为我验证这一点吗?

标签: java android google-maps


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2015-12-24
    • 2017-08-04
    • 2017-07-25
    • 2014-05-11
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2020-12-10
    • 2016-06-24
    相关资源
    最近更新 更多