2017-01-21 39 views
0

我的XML滚动布局(工作正在进行中)看到是这样的:Android的滚动布局 - 观点没有方向变化

<?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 有没有人对这里发生了什么有线索?谢谢。

+0

不作滚动视图直接的XML。使线性布局,并把滚动视图在它 –

+0

试过了,但是这会导致只有一排列表视图是显示在屏幕上。 – Gruiberg

回答

0

这是你需要的布局:

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

您还可以查看如何将你的布局是在横向模式,同时构建它:

enter image description here

+0

这是快速和高效的!非常感谢的人,你是一个保护程序:) – Gruiberg

0

似乎你缺少结束标记滚动视图。

+0

你说得对,我没有正确的问题贴吧,但它在代码呈现,所以这(是)不是问题。 – Gruiberg