但是layout_width
仅限于60dp
,因此实际上显示为:
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/greentick"
android:id="@+id/imageButton"
android:background="@drawable/my_button_bg"/>
</LinearLayout>
背景(my_button_bg.xml
):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#00FF00" />
</shape>
如何调整布局以使其显示为第一张图片,但layout_width
保持不变?