Android: Quelle est la meilleure mise en page pour une utilisation en essayant d'obtenir des boutons d'image 2x2, et plus encore?
-
27-09-2019 - |
Question
Je suis en train de faire mon regard de mise en page comme si. J'ai essayé gridviews, mises en page de table, et plus mais ne peux pas obtenir de regarder à droite. Je veux quelque chose comme ça.
ImageButton ImageButton2
ImageButton3 ImageButton4
ImageView1
ImageButton5 ImageButton6
ImageButton6 ImageButton7 ImageButton8 (ce sont des icônes plus petites)
ImageButton9 (small donate button)
Je viens de cant semblent comprendre comment obtenir la mise en page de travailler avec imagebuttons. Que dois-je utiliser la mise en page? Pourriez-vous le code postal exemple de la mise en page XML si possible?
La solution
vous pouvez faire quelque chose comme ça, mais il peut y avoir une autre façon de le faire:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ImageView android:layout_width="wrap_content" android:src="@drawable/icon"
android:layout_height="wrap_content" android:layout_gravity="center"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ImageView android:layout_gravity="center" android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
ici est le résultat. J'ai jeté ensemble un projet Android et juste utilisé l'image qui est par défaut pour l'icône.
Autres conseils
Peut-être que cela peut vous aider:
DroidDraw - Interface utilisateur (UI) concepteur / éditeur pour la programmation avec Android
Vous pouvez utiliser l'éditeur graphique pour rendre votre mise en page, et générer le XML.