[Solved] Change background on click [duplicate]


for this you have to create a two layout inside one main linear layout and give layout width and height both fill parent. Make one of the layout invisible by default and make it visible in the layout click of the another layout.

<Linearlayout android:layout_width="fill_parent" 
android:layout_height="fill_parent">

  <Linearlayout android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/layout2"
    android:background="@drawable/background1">
  </Linearlayout>

  <Linearlayout android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/layout2"
    android:background="@drawable/background2">
  </Linearlayout>
</Linearlayout>

In your activity in your layout click handle like this (not exactly),

// Enable Layout 2 and Disable Layout 1
  Layout1 .setVisibility(View.GONE);
  Layout2.setVisibility(View.VISIBLE);

solved Change background on click [duplicate]