2016-09-24 4 views
0

丸い形の画像ボタンを取得しようとしました。しかし、それは正方形の背景を持つ円形のイメージを表示していますが、私はバックグラウンドのないイメージだけが必要です。 round_image.XMLもバックグラウンド描画可能ファイルとして使用しましたが、動作しません。アンドロイドスタジオでラウンド画像ボタンを取得する方法

<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" android:background="@drawable/round_image"/> 

round_image.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"> 
<gradient android:startColor="#50d050          
android:endColor="#008000" android:angle="270"/> 
<stroke 
android:width="1px" 
android:color="#000000"/> 
</shape> 
+0

のこのコーナーは、あなたがこの1 http://stackoverflow.com/を試してみました

menu.xml質問/ 9884202 /カスタムサークルボタン –

+0

うん!しかし、私は使用していない状態を使用していませんでした。私はセレクタを使用しようとしました。 –

+0

Possilble複製:http://stackoverflow.com/questions/21397115/rounded-image-button-android –

答えて

0

利用代わりにあなたの

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@color/colorPrimary" /> 
    <stroke android:color="@color/colorPrimary" /> 
    <corners 
     android:bottomLeftRadius="5dp" 
     android:bottomRightRadius="5dp" 
     android:topLeftRadius="5dp" 
     android:topRightRadius="5dp" /> 
</shape> 
+0

私もそれを試してみましたが、うまくいきませんでした。 –

+0

イメージsrcを使用していると思うので、設定した背景が上書きされます。イメージsrc @RohithaAgina –

関連する問題