Q:

Is possible to set background for LinearLayout from the Activity file?

This is my xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:background="@color/blue"
android:gravity="center">

Is possible to set color from my Activity file?
For example I can do that for a button:
ImageButton x = (ImageButton) this.findViewById(R.id.btn1);
x.setBackgroundColor(color);

A:

Yes, you can  do it by
public class MainActivity {
   private LinearLayout ll;

    @Override
    public void onCreate(...) {
      super.onCreate(...);
      setContentView(R.layout.your_layout_name);
      ll = (LinearLayout) findViewById(R.id.linear_layout_id);

      // You can set Background Color for your Linear Layout
      ll.setBackgroundColor(Color.RED);
      // You can set Image Also
      ll.setBackgroundResource(R.drawable.imagename);
 }
}

In XML file :
    <LinearLayout 
            android:id="+@id/linear_layout_id"
            android:width = "fill_parent"
            android:height = "fill_parent"
            android:orientation = "vertical"
    />

