To change background color dynamically follow the code.
If you have the textview and id is myview.
<TextView android:id="@+id/myview"/> TextView myview=(TextView) findViewById(R.id.myview);
If you want to set simple background color then do this
myview.setBackgroundColor(Color.RED);
If you want set background image then
myview.setBackgroundResource(R.drawable.backgroundimg);
If you want to set background color with rgba then
myview.setBackgroundColor(Color.argb(255, 255, 255, 255))
Question and answer is powered by AnsPress.io