我试图在一个Android ImageButton上弄圆角,代码看起来像这样;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_marginTop="57dp"
android:src="@drawable/friends"
android:padding="1dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/imageButton2"
android:layout_marginRight="62dp" />
</RelativeLayout>
</LinearLayout>
基本上,我们的输出是一个ImageButton,但它具有四角形,我们正在尝试四舍五入这些角。
谢谢
在Android中使用Shape制作圆角
创建名为的xml文件 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="4dp" />
</shape>
在您的ImageButton中添加此属性 android:background="@drawable/roundcorner"
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_marginTop="57dp"
android:src="@drawable/friends"
android:background="@drawable/roundcorner"
android:padding="1dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/imageButton2"
android:layout_marginRight="62dp" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句