【发布时间】:2014-12-25 09:09:19
【问题描述】:
我正在尝试制作一个圆形的 Android ImageButton。为此,我根据link编写如下代码。
在我的 main.xml 中
<?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="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:textColor="#333"
android:textSize="18sp"
android:text="Invite Activity." />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/round"
android:background="@drawable/roundcorner"
android:padding="50dp" />
</LinearLayout>
在我的 res/drawable/roundcorner.xml 中
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#33DDFF" />
<corners android:radius="100dp" />
</shape>
但是代码不起作用。输出如下
但是,当我在 main.xml
中将 ImageButton 更改为 ImageView<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/round"
android:background="@drawable/roundcorner"
android:padding="50dp" />
如下所示
我很困惑,因为我知道 ImageButton 继承自 ImageView。为什么它的工作方式不同?有没有什么办法解决这一问题?提前致谢!
【问题讨论】:
-
你能发布完整的 xml...
-
我已经更新了完整的 xml
标签: android xml background imageview imagebutton