Image full screen, round corners

Well .. I have some ImageButtons buttons in an Android app. I want them to display the full picture. I mean: I want ImageButton to be just a picture, you know?

Good ... bye, so good ... I can do this using the "background" property.

However, I also want the ImageButton to have rounded corners.

I have the following xml in my layout folder:

    <?xml version="1.0" encoding="UTF-8"?>
        <shape xmlns:android="http://schemas.android.com/apk/res/android">
            <solid android:color="#FFFFFFFF"/>
            <corners android:radius="10dip"/>
            <stroke android:width="8dip"/>
        <size android:height="8dip"/>    
        </shape>

It works great when I don't want the image to fill the WHOLE ImageButton ... however, when I try to use the image to use the whole image, it doesn't show rounded corners.

Can someone help me please?

Bonus question: Also, how can I have a beautiful black line (rounded corners) around the image button?

+5
3

ImageView ImageButton onClick(). xml , :

image_bg.xml: ( XML )

<?xml version="1.0" encoding="UTF-8" ?> 
  <shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#000000" /> 
  <stroke android:width="3dp" android:color="#776da8" /> 
  <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /> 
  <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> 
  </shape>

( xml, ), :

<ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/image" 
           android:src="@drawable/icon"
           android:background="@drawable/image_bg" /> 
+10

? , . , " ", . imageview, onclick. , , , , new/other/android. . , !

+2

, . , , .

ImageView ?

onClick .

+1

All Articles