2017-06-13 59 views
0

所有的屏幕我做它采用动态表的应用程序,我的XML代码:Android的23和更小的不用填横向模式

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_weight="1" 
android:scrollbars="none"> 

<include 
    android:id="@id/action_bar" 
    layout="@layout/actionbar_toolbar" /> 

<HorizontalScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/action_bar"> 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <TableLayout 
      android:id="@+id/table" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:stretchColumns="*"> 

     </TableLayout> 
    </ScrollView> 
</HorizontalScrollView> 

表采取一切值在代码。我的问题是,在Android的23少,当你把屏幕方向在横向模式下,屏幕看起来像:

landscape 23

但在Android版本24及以上,屏幕看起来不错:

landscape 24

PD:match_parent属性不起作用。

回答

0

不知道它为什么显示不同,从我可以理解它显示,因为它应该考虑布局属性(即所有wrap_content),没有什么可以指示它应该填充父项。 但是,改变水平滚动视图的fillViewPort属性,并将它的宽度改为match_parent,就可以实现这个技巧。

https://developer.android.com/reference/android/widget/ScrollView.html#attr_android:fillViewport

... 
    <HorizontalScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true"> 
    ... 
相关问题