I am making a background shape for EditText - xml below:
<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/WhiteSmoke"/>
<stroke android:width="1dp" android:color="@color/aadhaar_logo_brown" />
<padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" />
<corners android:topRightRadius="10dp" />
<gradient android:startColor="@color/White"
android:centerColor="@color/White"
android:endColor="@color/White"
android:angle="0"/>
</shape>
However I require an image on the right hand side of the EditText to indicate mandatory field. I tried adding the image programmatically but the image does not show up in the runtime
((EditText) findViewById(R.id.txt_enduser_name)).setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.ic_mandatory_text_field), null);
Please help
You need to provide an "intrinsic size" to the shape:
Then, you can just set it as the
drawableRight
: