android:如何添加图片按钮?
问题描述:
我想用imagebutton替换我以前的丑文字按钮。但是,使用以下ImageButton代码更改XML文件后,我的应用程序甚至无法启动。为什么?android:如何添加图片按钮?
<ImageButton
android:layout_height="fill_parent"
android:id="@+id/refresh"
android:src="@drawable/refresh"
/>
答
原来,我忘了layout_width属性。它现在有效。
<ImageButton
android:layout_height="fill_parent"
android:id="@+id/refresh"
android:src="@drawable/refresh"
android:layout_width="wrap_content"
/>
答
指定布局宽度..
android:layout_width="wrap_content/*some value ex:50dp*/"