Reputation: 14845
I'm currently using the XML layout to set my Activity background. How can I do this in the Java code instead?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >
Upvotes: 1
Views: 128
Reputation: 2414
Before calling Activity.setContentView(View)
use one of the setBackground...()
methods on your main View
.
Upvotes: 2
Reputation: 1497
Set an id attribute to your parent RelativeLayout. Than find it by id in activity code and use setBackgroundResource method.
Upvotes: 1