2017-06-13 4 views
0

je fais une application qui utilise des tables dynamiques, mon code XML est:Android 23 et plus petits ne remplissent pas tous l'écran en mode paysage

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

Le tableau prend toutes les valeurs de code. Mon problème est que dans Android 23 et moins, lorsque vous mettez l'orientation de l'écran en mode paysage, l'écran ressemble à:

landscape 23

Mais dans la version Android 24 et ci-dessus, l'écran semble bon:

landscape 24

PD: match_parent La propriété ne fonctionne pas.

Répondre

0

Je ne sais pas pourquoi l'affichage est différent, d'après ce que je peux comprendre, il doit afficher les attributs de disposition (c'est-à-dire tout wrap_content), rien n'indique qu'il doit remplir le parent. Toutefois, la modification de l'attribut fillViewPort du ScrollView horizontal et de sa largeur par match_parent fait l'affaire.

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