How can I display text above a button?
Only the button displays, but I want to see the text above the button
<RelativeLayout
android:id="@+id/big_button_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<ImageButton
android:id="@+id/big_button"
android:layout_width="match_parent"开发者_StackOverflow中文版
android:layout_height="match_parent"
android:src="@drawable/girrafffe"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="Hello"
android:layout_above="@id/big_button"/>
</RelativeLayout>
<Button
android:id="@+id/button_send"
android:layout_width="150px"
android:layout_height="wrap_content"
android:padding="20dp"
android:drawableBottom="@drawable/image"
android:background="@android:color/transparent"
android:text="@string/send"
android:gravity="center"
android:layout_gravity="center"
/>
android:drawableBottom="@drawable/image"
will place the image of the button on the bottom thus allowing the text to be placed on the top.
Use a TextView.
<RelativeLayout
android:id="@+id/big_button_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="Big Button"/>
<ImageButton
android:id="@+id/big_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/girrafffe"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_above="@id/big_button"/>
</RelativeLayout>
You may need to add some layouts to line everything up. However, this may work without them.
精彩评论