J'essaie de faire une barre de menu horizontale, mais pour une raison quelconque, lorsque j'utilise des poids, ils ne s'alignent pas horizontalement, des suggestions?Les images ne sont pas centrées lors de l'utilisation de layout_weights
<LinearLayout
android:id="@+id/bottombuttonslayout"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:weightSum="1.0" >
<LinearLayout
android:id="@+id/listSlotBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:gravity="center" >
<ImageView
android:id="@+id/listSlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:background="@drawable/list" />
</LinearLayout>
<LinearLayout
android:id="@+id/leftArrorSlotBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".20" >
<ImageView
android:id="@+id/leftArrowSlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:background="@drawable/left_arrow" />
</LinearLayout>
<LinearLayout
android:id="@+id/playSlotBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".20" >
<ImageView
android:id="@+id/playSlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:background="@drawable/playing" />
</LinearLayout>
<LinearLayout
android:id="@+id/rightArrowSlotBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".20" >
<ImageView
android:id="@+id/rightArrowSlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:background="@drawable/right_arrow" />
</LinearLayout>
Voici à quoi cela ressemble, ils s'alignent verticalement. non horizontalement:
EDIT
Ce qui suit est la première suggestion:
Ils ne seront pas alignés horizontalement parce que 'Android : layout_gravity = "center" 'ne fonctionnera que verticalement pour un' LinearLayout 'orienté horizontalement (et vice versa pour un orienté verticalement). Avez-vous essayé d'ajouter 'android: gravity =" center "' sur les LinearLayouts imbriqués à la place? Alternativement, vous pouvez toujours les échanger pour quelque chose comme un «FrameLayout» ou «RelativeLayout», ce qui vous donnera un peu plus de contrôle sur le positionnement. –