J'ai un LinearLayout avec plusieurs enfants et je veux le ListView pour remplir la moitié inférieure restante de la mise en page de parent:Poids en LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
>
<AutoCompleteTextView
android:id="@+id/from_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:hint="@string/hint_from"
android:singleLine="true"
android:imeOptions="actionNext"
/>
<AutoCompleteTextView
android:id="@+id/to_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="@string/hint_to"
android:singleLine="true"
android:imeOptions="actionSearch"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/inverse_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".4"
android:layout_margin="10dp"
android:text="@string/inverse"
android:onClick="onClick"
/>
<Button
android:id="@+id/search_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".6"
android:layout_margin="10dp"
android:text="@string/search"
android:onClick="onClick"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:background="@color/holo_blue_dark"
/>
<ListView
android:id="@+id/favorites_lv"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight=".5"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_gravity="bottom"
android:background="#700"
/>
</LinearLayout>
Mais j'obtenir ce résultat:
En outre, comme vous pouvez le voir, il existe un problème avec la hauteur des éléments ListView. La mise en page:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_mylocation"
android:contentDescription="@string/favorites_icon_cd"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:orientation="vertical"
android:gravity="left|center_vertical"
>
<TextView
android:id="@+id/from_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
/>
<TextView
android:id="@+id/to_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
/>
</LinearLayout>
</LinearLayout>
Comment résoudre ces problèmes?
Merci, le 1er problème est résolu, et qu'en est-il du 2ème? – arts777
Désolé je n'ai pas vu la deuxième question, j'ai mis à jour ma réponse. – Sam
essayé les deux solutions possibles sans résultat :( – arts777