Scrollview problem
In an activity, I have list of buttons and a listview. For every category I have a button and on click of that it shows corresponding data.Here is my xml code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_1"
android:text="first"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_2"
android:text="second"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_3"
android:text="three"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_4"
android:text="four"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_5"
android:text="five"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_6"
android:text="six"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_7"
android:text="seven"
/>
<Button android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="@+id/button_8"
android:text="eight"
/>
<ListView android:id="@+id/list" android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
</LinearLayout>
In this activity, first buttons are visible. Then on click of button, all buttons will be invisible and only 开发者_运维知识库list view is there. Problem is If I am using scroll view, I can scroll button but only half of list view can be seen means I cannot scroll it. If I am not using scroll view, I can scroll the list view but not buttons. Can anybody please help me, where I am wrong? Thank you..
Do NOT put a ListView inside a ScrollView. ListView already handles
scrolling, you're only going to run into trouble.
In you case you can keep all the Button
in a seperate xml layout
with scroll and ListView
in a seperate layout and use the addHeaderView
property of ListView
and add the layout of button's.
Example of addHeaderView in
ListView
My suggestion is to just put the buttons as a listview header. This way you can scroll everything without the need for a ScrollView.
see ListView.addHeaderView
精彩评论