I have requirement like this- my activity contains some textviews at the top then the expandable list view in the middle and a button at the bottom. my problem is when i clicked on
expandable list view the expan开发者_高级运维ded list get accommodated in the space between button and expandable list view.I wanted expandable list view to get expanded full and button should move downward according to the contains of the expandable list view. And i have used scrollview as a main layout.
thank youIs this a LinearLayout with android:layout_weight attributes ?
Instead of using ScrollView as the main layout, use a LinearLayout but without the Button. For eg:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ExpandableListView
android:id="@+id/expandableListView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ExpandableListView>
</LinearLayout>
Now in code, add the Button as the footerView of the ExpandableListView as :
final ExpandableListView elv = (ExpandableListView) findViewById(R.id.expandableListView1);
Button btn = new Button(this);
elv.addFooterView(btn);
The button will always be present at the end of the ExpandableListView using this. Just as you want it to be.
You should place your expandable Listview and your button in a relative layout, and set align below is your button, It works for me.
Custom ExpandableListView Tutorial
http://www.mysamplecode.com/2012/10/android-expandablelistview-example.html
精彩评论