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 expanded 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 you
这是具有android:layout_weight属性的LinearLayout吗?
您应该将可展开的Listview和按钮放置在相对的布局中,并在按钮下方设置align,这对我有用。
Custom ExpandableListView Tutorial
http://www.mysamplecode.com/2012/10/android-expandablelistview-example.html
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.