Reputation: 29
In my project I used setcontentview(R.layout.first).here
. In a gallery I am displaying second.xml
. In second.xml
I have one listview.when
. I am trying to scroll these listviewitems
total screen scrolling, but it is not scrolling properly. Because outside we used scrollview. When I delete outside scrollview we cannot see the bottom of listview
. How to resolve this issue?
Upvotes: 1
Views: 858
Reputation: 34301
I have no any ready example with me,
So written a raw code like this as you asked in comment,
ListView lv = (ListView) findViewById(R.id.listView);
LinearLayout ll = new LinearLayout(this);
ll.setLayoutParams(new LinearLayout.LayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)));
Button btn = new Button(this);
ll.addView(btn);
lv.addFooterView(ll, null, true);
Upvotes: 0
Reputation: 5417
ListView inside ScrollView is not possible.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- here the picture info -->
</LinearLayout>
</LinearLayout>
Upvotes: 0
Reputation: 10005
Use ListView
's headers and footers if you want to put some items only at the end/beginning of the ListView
.
Watch this video beginning from 42:40 it's really useful.
Upvotes: 1
Reputation: 1641
If you put your ListView/any scrollable View inside the scrollView it will not work properly because when you touch the screen ,main focus of your touch is on parent view(scrollView ) not the child View (ListView).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<ListView android:layout_height="match_parent" android:id="@+id/all_workouts_list"
android:cacheColorHint="#ffffffff"
android:layout_width="match_parent"
android:layout_above="@+id/add_workout_all_workout_list"></ListView>
<Button android:layout_width="wrap_content"
android:id="@+id/add_workout_all_workout_list" android:layout_height="wrap_content"
android:text="Add Workout" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"></Button>
</RelativeLayout>
Upvotes: 0
Reputation: 20587
A list view will scroll automatically once it goes past its parents height or the ListViews maximum height
Upvotes: 0