Problème de mise en page Android - largeurs relatives en pourcentage en utilisant le poids
Je suis en train d'affecter la largeur relative à des colonnes dans une liste qui est dans un TabHost, à l'aide de layout_weight comme l'a suggéré ici:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/triplist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="4px">
<TableRow>
<ListView android:id="@+id/triplistview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<Button android:id="@+id/newtripbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Trip"/>
</TableRow>
[other tabs ...]
Ma définition de ligne a 4 colonnes que je tiens à la taille comme suit:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1.0"
android:padding="4px">
<TextView android:id="@+id/rowtripdate"
android:layout_weight=".2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:inputType="date"/>
<TextView android:id="@+id/rowodostart"
android:layout_weight=".2"
android:layout_width="0dip"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/rowodoend"
android:layout_weight=".2"
android:layout_width="0dip"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/rowcomment"
android:layout_weight=".4"
android:layout_width="0dip"
android:layout_height="wrap_content">
Malheureusement, il semble vouloir s'adapter à toutes les colonnes dans l'espace que le bouton occupe, par opposition à la largeur de l'écran. Ou peut-être il y a une autre contrainte que je ne comprends pas. Je vous remercie de votre aide.
le texte d'alt http://heeroz.com/layoutprob.png
source d'informationauteur cdonner
Vous devez vous connecter pour publier un commentaire.
Je crois que j'ai oublié cette propriété pour le TableLayout élément:
Il semble fonctionner maintenant.
Je ne vois rien évidemment faux dans ce que vous montrez là. Pour obtenir une meilleure image de ce qui se passe, vous pourriez essayer la hiérarchie de la visionneuse. Il est livré avec le SDK. Il permettra de visualiser la quantité d'espace chacun de la "caché" des couches, de sorte que vous pouvez comprendre que l'on a décidé à n'être que les grands.