0

So I am putting a button on my page, I have both an Image Button and a Button. I place my mybutton3.xml but I get just the image on the button with no outline, or an image and outline in the Image Button just at a huge size without the option to re-size without cropping the image out.

How can I show the image which is a .png with the ButtonStyle.xml?

This is my mybutton3.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <corners android:radius="50dip" />
            <stroke android:width="1dip" android:color="#000000" />
            <gradient android:angle="-90" android:startColor="#1DA4FF" android:endColor="#FFFFFF"  />
        </shape>
    </item>
    <item android:drawable="@drawable/settings">
        <shape android:shape="rectangle">
           <corners android:radius="50dip" />
           <stroke android:width="1dip" android:color="#000000" />
           <gradient android:angle="-90" android:startColor="#FFFFFF" android:endColor="#FFFFFF" />
       </shape>
   </item>

This is my activity with the two buttons existing

<Button
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:text="Play Games"
        android:id="@+id/PlayGamesBtn"
        android:background="@drawable/mybutton3"
        android:textSize="20px"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true" />
<ImageButton
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:id="@+id/imageButton"
        android:src="@drawable/settings"
        android:background="@drawable/mybutton3"
        android:layout_centerVertical="true"
        android:layout_toStartOf="@+id/PlayBtn" />
teobais
  • 2,820
  • 1
  • 24
  • 36
Raj
  • 35
  • 6
  • To begin with, did you close the `selector` tag on `mybutton3.xml`? In addition, you didn't define the `ButtonStyle.xml`: is it the last code snippet? – teobais Dec 12 '15 at 21:53
  • sorry the Button.xml is called mybutton3, and I do close the selector tag, must have missed that part of the code, sorry @toubou – Raj Dec 12 '15 at 22:33
  • try `android:drawableTop="@drawable/mybutton3.xml"` in the button – Daniel Kobe Dec 12 '15 at 23:32
  • hi @DanielKobe, put the android:drawableTop, I've tried that and it just shows the top half of the image, rather than putting the image on top – Raj Dec 13 '15 at 00:07
  • What about giving the shape an outline ? ` ` – Daniel Kobe Dec 13 '15 at 00:12
  • I have included those @Daniel Kobe, what happens is the PNG image, covers the white circle which i have created. i need it to be on top of the white circle but to go inside it instead cover it. – Raj Dec 13 '15 at 00:24
  • What about using a layer list http://stackoverflow.com/questions/21002224/add-a-background-image-to-shape-in-xml-android – Daniel Kobe Dec 13 '15 at 00:25

0 Answers0