I just working on demo app where I require to set the the border width and the border color programmatically.
I know that can be done using the xml drawable but I want to do all these at run time. I know it is good to have these by creating the xml and use it but my requirement is such dynamic so I have to do all these stuff at runtime instead of below approach.
border_edittext.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#000000"/>
</shape>
Setting the drawable.
EditText foo = (EditText)findViewById(R.id.editText);
foo.setBackgroundResource(R.drawable.border_edittext);
Thanks in advance.