Android Studio XML Requires Layout_Height and Layout_Width



I found this code while searching for button with good graphics,



<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg" android:shape="rectangle" >
<corners
android:radius="100dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#7995A8"
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>


however, when i copy paste it into and xml file in android studio, it shows and error that says, "element shape does not have required attribute android:layout_height" and another error for "element shape does not have required attribute android:layout_width"


i tried setting the android:layout_width="" and android:layout_heigth"" and android:layout_width"wrap_content",android:layout_heigth="wrap_content", the error is gone, but i can't set any button to have this as it's background ... so i can't use this xml this way.


what should i set them to ?


No comments:

Post a Comment