Reputation: 6620
I have a button, the button has a background and a src Image icon. Now I want to have a text on the bottom, inside my button.
How can I achieve this?
I cannot use ImageButton as it doesn't handle text. Also I cannot use Button as it doesn't handle src Image.
Upvotes: 0
Views: 112
Reputation: 24853
Try this..
Use android:drawableTop="@drawable/ic_launcher"
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_launcher"
android:text="Button" />
Or
<RelativeLayout
android:id="@+id/btn_lay"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:gravity="center"
android:text="Cal" />
</RelativeLayout>
ClickListener
RelativeLayout btn_lay = (RelativeLayout) findViewById(R.id.btn_lay);
btn_lay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Do Something
}
});
Upvotes: 3