2015-01-21 17 views
11

Các bạn tôi đã tạo một imageButton trong tệp bố cục của mình và đặt hình ảnh png tròn làm hình nền. Nhưng khi tôi chạy ứng dụng của mình, nó hiển thị cho tôi một nút hình vuông với hình ảnh được đặt ở giữa của nó.cách tạo imageButton tròn trong Android?

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:src="@drawable/sliderr" /> 
+0

bạn có thể làm điều này bằng cách mã. –

Trả lời

24

thêm android:background="@null"

+3

chỉ cần trả lời đơn giản –

5

cố gắng để thêm xml này ..

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<solid android:color="#eeffffff" /> 
<corners android:bottomRightRadius="8dip" 
    android:bottomLeftRadius="8dip" 
    android:topRightRadius="8dip" 
    android:topLeftRadius="8dip"/> 
</shape> 
3
use shape as follows 
<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 
<gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" 
    android:angle="270"/> 

Các vấn đề liên quan