[英]Android - A button with Image + background + text
我有一个按钮,该按钮有一个背景和一个src图像图标。 现在,我想在按钮底部的底部显示一个文本。
我该如何实现?
我不能使用ImageButton,因为它不处理文本。 我也不能使用Button,因为它不能处理src图像。
尝试这个..
使用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" />
要么
<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
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.