Hello I am trying to set the background image on the LinearLayout
, first I need to make it rounded that I made using shape
tag and calling setBackgroundResource
to make it rounded but now how should I set any drawable also at run time on same LinearLayout
layout_rounded.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="3dip" android:color="#B1BCBE" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
and I did this
linearLayout.setBackgroundResource(R.drawable.layout_rounded);
Here to set the background on the LinearLayout
then I have to call the setBackgroundDrawable
but after calling this, it set the drawable but again it unset the shape of the LinearLayout
.
I don't have that drawable in res, that background I am getting from URL then trying to set
Can you please look how to achieve this ?
Thanks in advance