Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Text Below Icon (button)

I am trying to create a main entry interface. I will create a six buttons, and each button will open another activity. For each button, I want it have an big icon with text below the button. Currently, I can have image on the button, but I do not know how to make the text to display below the button. I tried to place the text directly on the image, but it doesn't look good. Here is the portion for the first row (two buttons) of button

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal"
    android:weightSum="2" >

    <Button
        android:id="@+id/btn1"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/ic_my_icon" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/ic_my_icon2" />
</LinearLayout>

This is what I am talking about. Other than that I want the icon to be an oval button. The result I want kind of look like the image in this post, except I would like six oval button with images and text. Round buttons with icon in center and text under icon

Thank you very much for your help.

like image 499
user3550749 Avatar asked Apr 19 '14 03:04

user3550749


1 Answers

Use drawableTop attribute as follows:

<Button
    android:id="@+id/btn2"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="This text is below the image"
    android:drawableTop="@drawable/ic_my_icon2" /> 

See the reference android:drawableTop and this simple example on Button documentation with drawableLeft.

like image 64
Blo Avatar answered Oct 23 '22 05:10

Blo