1

activity_main.xml

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="200sp">
        <Button
            android:id="@+id/makepro"
            android:text="Button"
            android:textColor="#FFFFFF"
            android:textSize="30sp"
            android:layout_width="270dp"
            android:layout_height="60dp"
            android:background="@drawable/buttonshape"
            android:shadowColor="#A8A8A8"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="5"
            />
    </LinearLayout>

Here I try to remove the Linear Layout to see if it works but not working.

buttonshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <corners
        android:radius="14dp"
        />
    <gradient
        android:angle="45"
        android:centerX="35%"
        android:centerColor="#47A891"
        android:startColor="#E8E8E8"
        android:endColor="#000000"
        android:type="linear"
        />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp"
        />
    <size
        android:width="270dp"
        android:height="60dp"
        />
    <stroke
        android:width="3dp"
        android:color="#878787"
        />
</shape>

Button did not change background and I can't find the mistake. Can you help me? I try to find something similar to my problem, with not helpful result.

greybeard
  • 2,249
  • 8
  • 30
  • 66
jMpro
  • 13
  • 6

1 Answers1

0
 I use Textview instead of Button then Background Image is display. You can also use ImageButton instead of 
 button . try below code . it is working.  
 <TextView
 android:id="@+id/makepro"
 android:text="Button"
 android:gravity="center"
 android:textColor="#FFFFFF"
 android:textSize="30sp"
 android:layout_width="270dp"
 android:layout_height="60dp"
 android:background="@drawable/buttonshape"
 android:shadowColor="#A8A8A8"
 android:shadowDx="0"
 android:shadowDy="0"
 android:shadowRadius="5"/>