Android Mise en page - layoutweight et weightsum

J'ai besoin de construire une mise en page avec l'ensemble des linéaires mises en page. La mise en page doit occuper un pourcentage défini de l'écran. J'ai besoin de le faire pour avoir un look similaire dans tous les dispositifs.

Question:

J'ai un textview en haut à droite de mise en page (couleur verte de la boîte ). Chaque fois que j'ajoute des données dans le textview il perturbe toute la mise en page comme indiqué ci-dessous dans la 2ème image. Mais j'ai besoin d'avoir les données ajuste automatiquement lorsqu'il atteint l'extrémité droite de l'écran/mise en page.

Merci de m'aider à résoudre ce problème. Merci D'Avance

Image1 - vue Graphique que par le XML indiqué ci-dessous

Android Mise en page - layoutweight et weightsum

Image2 - Montre comment la mise en page change automatiquement, lorsque j'ajoute des données dans le textView

Android Mise en page - layoutweight et weightsum

xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" 
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:layout_weight="91"
android:weightSum="100">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" 
android:layout_weight="40"
android:weightSum="235">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:orientation="vertical"  
android:gravity="center"
android:background="#ff0000"
android:layout_weight="100">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:orientation="vertical"   
android:background="#ffff00"
android:layout_weight="45">   
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tvItemName" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ViewFlipper>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:orientation="vertical"  
android:background="#ffffff"
android:layout_weight="90">   
</LinearLayout> 
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" 
android:layout_weight="60"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:orientation="vertical"   
android:layout_weight="30"
android:background="#00ab00"
android:weightSum="100"> 
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:textColor="#000000"
android:text="Test data" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="#cd00ab" 
android:layout_weight="70"> 
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" 
android:background="#ab0000"
android:layout_weight="9">
</LinearLayout>
</LinearLayout>

OriginalL'auteur iappmaker | 2013-03-29