Reputation: 3102
I'm creating a custom background with an arrow on the right. I can't seem to control the padding of the drawable; it is right next to the right edge. I would like to control the offset from the right. I've tried adding android:right
and other <margin...
attributes with no effect.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="#bbbbbb"/>
<stroke android:width="1dip" android:color="#000000" />
<corners android:radius="5dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
<item>
<bitmap
android:gravity="right"
android:src="@drawable/btn_dropdown_arrow" />
</item>
Upvotes: 0
Views: 2744
Reputation: 3633
Just create the shape using below code..
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#bbbbbb" />
<stroke
android:width="1dip"
android:color="#000000" />
<corners android:radius="5dip" />
</shape>
Then apply this to the background of the View. In that view we have attribute like drawable_right
.
<android:drawable_right="@drawable/btn_dropdown_arrow">
Upvotes: 1
Reputation: 2505
Use of a right
inset attribute in the bitmap
's item
tag will give the bitmap padding on the right:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="#bbbbbb"/>
<stroke android:width="1dip" android:color="#000000" />
<corners android:radius="5dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
<item android:right="10dp">
<bitmap
android:gravity="right"
android:src="@drawable/btn_dropdown_arrow" />
</item>
Upvotes: 1