Reputation: 56249
I have three Relative layouts in may app, on above another.
<RelativeLayout_1><CheckBox></CheckBox></RelativeLayout>
<RelativeLayout_2></RelativeLayout>
<RelativeLayout_3></RelativeLayout>
First is at top, and third is at bottom. When I click on check box in my first layout, second layout is visible/unvisible. How to achive that I always see third layout at bottom and put scrollbar at second when is visible ? ( Second have lot off content so when is visible, third layout is vanished ).
Upvotes: 0
Views: 665
Reputation: 23873
Try
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#888888"
android:id="@+id/relativeLayout1">
<RelativeLayout
android:layout_height="wrap_content"
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:background="#404000"
android:layout_alignParentTop="true">
<CheckBox
android:text="CheckBox"
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:onClick="myClickHandler"
android:layout_height="wrap_content"></CheckBox>
<CheckBox
android:text="CheckBox"
android:layout_height="wrap_content"
android:id="@+id/checkBox2"
android:onClick="myClickHandler"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"></CheckBox>
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_below="@+id/relativeLayout2"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_height="wrap_content"
android:id="@+id/relativeLayout3"
android:layout_width="fill_parent"
android:background="#000040"
android:orientation="vertical">
<TextView
android:layout_height="190dp"
android:id="@+id/textView1"
android:text="TextView1"
android:layout_alignParentTop="true"
android:background="#004000"
android:layout_width="wrap_content"
android:textSize="20pt"></TextView>
<TextView
android:layout_height="190dp"
android:id="@+id/textView2"
android:text="TextView2"
android:layout_width="wrap_content"
android:background="#000040"
android:layout_below="@+id/textView1"
android:textSize="20pt"></TextView>
<TextView
android:layout_height="190dp"
android:id="@+id/textView3"
android:text="TextView3"
android:layout_width="wrap_content"
android:background="#400000"
android:layout_below="@+id/textView2"
android:textSize="20pt"></TextView>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:layout_height="wrap_content"
android:id="@+id/relativeLayout4"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true">
<TextView
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:text="I'm a text view in bottom Rel Layout"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:background="#000000"></TextView>
</RelativeLayout>
</RelativeLayout>
And for the click handler
public void myClickHandler(View target) {
View rv = findViewById(R.id.scrollView1);
CheckBox cb1 = (CheckBox) findViewById(R.id.checkBox1);
CheckBox cb2 = (CheckBox) findViewById(R.id.checkBox2);
switch (target.getId()) {
case R.id.checkBox1:
cb2.setChecked(false);
break;
case R.id.checkBox2:
cb1.setChecked(false);
break;
}
rv.setVisibility(cb1.isChecked() ? View.VISIBLE : View.GONE);
}
Upvotes: 1