Android 可滚动布局 - 视图在方向更改时不可见
Android scrollable layout - views not visible on orientation change
我的 XML 可滚动布局(正在进行中)如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tvStatus"
android:text="0 SMS found"
android:textSize="15sp"
android:layout_width="120dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnExport"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:text="Export"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
当以纵向模式在测试设备上加载应用程序时,所有视图都会显示并可见:
portrait mode
当设备方向更改为水平时,只有布局的列表视图部分可见(?!?):
landscape mode
有人知道这里可能发生的事情吗?谢谢
这是您需要的布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvStatus"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="0 SMS found"
android:textSize="15sp"/>
<Button
android:id="@+id/btnExport"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:text="Export"
/>
</LinearLayout>
</LinearLayout>
您还可以查看您的布局在构建时如何处于横向模式:
您似乎缺少滚动视图的结束标记。
我的 XML 可滚动布局(正在进行中)如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tvStatus"
android:text="0 SMS found"
android:textSize="15sp"
android:layout_width="120dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnExport"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:text="Export"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
当以纵向模式在测试设备上加载应用程序时,所有视图都会显示并可见: portrait mode 当设备方向更改为水平时,只有布局的列表视图部分可见(?!?): landscape mode 有人知道这里可能发生的事情吗?谢谢
这是您需要的布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvStatus"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="0 SMS found"
android:textSize="15sp"/>
<Button
android:id="@+id/btnExport"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:text="Export"
/>
</LinearLayout>
</LinearLayout>
您还可以查看您的布局在构建时如何处于横向模式:
您似乎缺少滚动视图的结束标记。