Reputation: 365
I need help for a Layout in Android Studio.
I got Texts and Icons (5 each) and every text is associated with an icon.
Icon and text are vertically centered.
I need to put every texts and icon in a shape of a « + ». So one in center, top, bottom, left and right.
How can I group one text with its icon so I can interprete this as one element and got more easier to center for this layout ?
Thanks !
You will find the result I have to match :
Upvotes: 1
Views: 159
Reputation: 3268
Just put them both in a layout view. like in a linearLayout with vertical orientation and set gravity to centerhorizontal. if you want to make it clickable just add an id to the linearlayout.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/image_text_element">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/settings"
android:layout_gravity="center_horizontal">
</ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:layout_gravity="center_horizontal" />
</LinearLayout>
Upvotes: 2
Reputation: 1033
How can I group one text with its icon so I can interprete this as one element and got more easier to center for this layout ?
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_text"
android:background="?android:attr/selectableItemBackground"
android:drawableTop="@drawable/your_icon"/>
Upvotes: -1