圆角的Android图像按钮 [英] Rounded corners android image buttons
本文介绍了圆角的Android图像按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想圆角在Android的ImageButton,在code看起来像这样;
I am trying to round corners on an android ImageButton, the code looks like this;
<?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的,但它的平方的角落,我们正试图四舍五入的角落。
Basically our output is an ImageButton but it has squared corners, we are trying to round off the corners.
感谢
推荐答案
使用<一个href="http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape">Shape在Android中,使圆边角
Use Shape in android to make the rounder corners
创建为 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添加此属性安卓背景=@可绘制/ roundcorner
In your ImageButton add this attribute 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" />
这篇关于圆角的Android图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文