0

J'ai créé une mise en page comportant un en-tête et un corps de défilement. Je suis en mesure de voir l'en-tête en mode portrait, mais quand il est entré en mode paysage ou que je dois le faire défiler, l'en-tête était manquant.Vues manquantes dans la vue paysage/défilement

Je voulais que l'en-tête reste statique, seul le corps devrait être défilé. Le côté gauche est en portrait et le côté droit est en paysage.

sample image

main_activity.xml

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="@dimen/padding_screenEdge" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <include layout="@layout/header_inspection"/> 

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

     <include layout="@layout/fragment_body"/> 

    </ScrollView> 
</LinearLayout> 

fragment_body.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
       android:orientation="vertical" 
      tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:background="@color/form_background"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:background="@color/form_background"> 

      <LinearLayout...> //header 

      <LinearLayout...> //column item 1 

      <LinearLayout...> //column item 2 

      <LinearLayout...> //column item 3 

      <LinearLayout...> //column item 4 

     </Linearlayout> 
</LinearLayout> 

header_inspection.xml
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="5" 
    android:orientation="horizontal"> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="start" 
     android:divider="@drawable/divider_vertical" 
     android:orientation="horizontal" 
     android:showDividers="middle" 
     android:dividerPadding="12dp"> 

     <TextView 
      android:id="@+id/btn_prev" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:gravity="end" 
      android:padding="@dimen/text_padding" 
      android:text="@string/btn_sebelumnya"/> 

     <TextView 
      android:id="@+id/btn_nxt" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:gravity="end" 
      android:padding="@dimen/text_padding" 
      android:text="@string/btn_seterusnya"/> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:gravity="end"> 

     <TextView 
      style="@style/marks" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="end" 
      android:text="Markah : "/> 

     <TextView 
      android:id="@+id/cur_marks" 
      style="@style/marks" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="start" 
      android:text="0"/> 

    </LinearLayout> 
</LinearLayout> 
+0

Votre "header_inspection_view" ne montre pas ici. Droite? – Ankita

+0

@Ankita oui, ma vue 'header_inspection' est manquante en mode paysage. si j'ajoutais l'en-tête à l'activité principale, l'en-tête serait défilé avec lui. Je préférerais que l'en-tête reste statique – xxmilcutexx

+0

Essayez de placer votre scrollview dans une disposition linéaire et définissez la propriété match_parent pour les deux dimensions (hauteur et largeur). – Ankita

Répondre

0

Je trouve le problème. Apparemment, j'aurais dû inclure le layout_height et layout_width en inclure tag. Par conséquent, le bon code pour main_activity devrait être:

main_body.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:padding="@dimen/padding_screenEdge" 
       tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik"> 

    <include layout="@layout/header_inspection" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent"/> 

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

     <include layout="@layout/fragment_lain2_generik"/> 

    </ScrollView> 


</LinearLayout> 
0

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
      xmlns:tools="http://schemas.android.com/tools" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content" 
 
       android:orientation="vertical" 
 
      tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik"> 
 

 
    <LinearLayout 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:orientation="vertical" 
 
     android:background="@color/form_background"> 
 

 
     <LinearLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="match_parent" 
 
      android:orientation="vertical" 
 
      android:background="@color/form_background"> 
 

 
      <LinearLayout...> //header 
 
      <ScrollView      
 
    android:layout_width="match_parent" 
 
    android:layout_height="wrap_content" 
 
    > 
 

 
      <LinearLayout...> //column item 1 
 

 
      <LinearLayout...> //column item 2 
 

 
      <LinearLayout...> //column item 3 
 

 
      <LinearLayout...> //column item 4 
 
</ScrollView> 
 
     </Linearlayout> 
 
</LinearLayout>

pour envelopper les essayer colonnes côté du scrollview et de garder la tête en dehors de scrollview