I have a RecyclerView inside a HorizontalScrollView. I don't see inside RecyclerView all the items. I have looked and even if the list in the adapter has 7 items, onBindViewHolder is called only 4 times! If I take out the HorizontalScrollView, it works ok.
I use the HorizontalScrollView because I need to scroll the list with the background of the recycle, not inside recycle, how it usually works.
So, I need a solution to scroll a list with the background of the list, or to show all the items using HorizontalScrollView
UPDATE :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:scrollbars="none"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/label">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/rlWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/paddingStartView"
android:background="#drawable/bg_round_corner">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/optionsRv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent" />
</RelativeLayout>
<View
android:id="#+id/paddingStartView"
android:layout_width="16dp"
android:layout_height="16dp" />
<View
android:id="#+id/paddingEndView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_toEndOf="#id/rlWrapper" />
</RelativeLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/label"
style="#style/FontLocalizedMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textAllCaps="true"
android:textColor="#979797"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Tempareature" />
</androidx.constraintlayout.widget.ConstraintLayout>
Make the child of the HorizontalScrollView to be RelativeLayout instead of LinearLayout
I just ran into this too, and the accepted answer helped. I had:
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none"
android:fillViewport="true">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/dates_recycler"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
and it didn't show all the items in the horizontally-oriented recycler view. It only showed enough items that would fit in the width of the device view, call onBindViewHolder that many times, etc. Adding a RelativeLayout in between the HorizontalScrollView and the RecyclerView fixed it, so that it showed all the items whether they fit all in the width of the device, or not, and you could scroll to reach them.
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/dates_recycler"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</HorizontalScrollView>
I think also setting the android:layout_width="match_parent" to the RelativeLayout is key.
onBindViewHolder is only called for the "visible on screen" items. If total item is 7 and the screen can only show 4, then everything is ok.
Hence the name "RecycleView", it recycles visible views, there are onle 4 views in total in your RecycleView
This I dont understand what you mean!?
I use the HorizontalScrollView because I need to scroll the list with
the background from recycle, not inside recycle, how it usually works.
So, I need a solution to scroll a list with the background of the
list, or to show all the items using HorizontalScrollView
Related
I'm making a simple custom navigation drawer for my android app and I have a ListView in it that populates with simple cursor adapter. After the listview I have some other views like textview and when the listview gets too much items no views after that show anymore. I tried the nested scroll views with coordinator and scroll view but it seems not just working. also i could use nested scroll view without fillViewport and give my list view a height but that doesn't seem so right so I wanted to see is there any other way to show the views after listview?
This is my navigation drawer layout:
<android.support.design.widget.CoordinatorLayout
android:background="#color/white"
android:layout_gravity="start|left"
android:layout_width="235dp"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="235dp"
android:background="#color/white"
android:layout_height="match_parent">
<LinearLayout
android:nestedScrollingEnabled="true"
android:layout_width="235dp"
android:background="#color/white"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textSize="17sp"
android:background="#6C6A6A"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Notes"/>
<ListView
android:id="#+id/notes_drawer_list"
android:entries="#array/drawer_all_notes_menu"
android:divider="#color/black"
android:dividerHeight="0.5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:textSize="17sp"
android:padding="5dp"
android:layout_width="match_parent"
android:background="#6C6A6A"
android:layout_height="wrap_content"
android:text="Tags"/>
<! the list view that is populated with cursor adapter!>
<ListView
android:id="#+id/tags_drawer_list"
android:divider="#color/black"
android:dividerHeight="0.5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:textSize="17sp"
android:padding="5dp"
android:layout_width="match_parent"
android:background="#6C6A6A"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
So i was searching for the answer for two days and i just seen this question that was asked some time ago and it was just perfectly working for my situation so i thought to send that questions link here.
Here is the answer:
ScrollView with a ListView doesn't scroll - android
I'm in stuck with my layout with a lot of recyclerViews (4).
If three recyclers have up to 20 items per each and they are GONE by default in xml, then fourth recycler has up to 100-400 items (not more) which are dynamically changing in code and it is VISIBLE by default.
I need to scroll (smoothly scroll, ofc) all of menu (layout) including all of it elements.
I was trying NestedScrollView, ScrollView for all layout, for pieces of layout, for recyclerViews.
I was trying this for RecyclerView: app:layout_behavior="#string/appbar_scrolling_view_behavior"
I was trying:
layoutManager.setAutoMeasureEnabled(true); //deprecated
recyclerView.setNestedScrollingEnabled(false);
I was trying android:descendantFocusability="blocksDescendants" for Nested
I was trying android:nestedScrollingEnabled="false" for RecyclerView
I was trying adapter.setHasStableIds(true);
I was trying to combine all of this things from stackoverflow and other resources.
I have achieved scrolling which I want just by simple adding NestedScrollView after my rootLayout (not smooth, but works correct), but only in AVD, real devices with up to 3GB RAM cannot handle adding of NestedScrollView - devices are getting infinite black screen and empty Logs.
Maybe I was trying to do something else and I've forgotten to type about them here. Comment about some another similar fixes and I will reply.
How I can achieve smooth scrolling all of rootLayout elements?
I know that rule about scrolling views inside of another scrolling views, but I need to scroll all of my scrollable recyclers.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:id="#+id/rootLayout"
android:background="#color/float_transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/LLMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/gray21"
>
<RelativeLayout
android:id="#+id/RLTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<View
android:id="#+id/BluecolorView"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#color/colorBlue"
>
</View>
<View
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#color/white"
android:layout_below="#+id/BluecolorView"
>
</View>
<FrameLayout
android:id="#+id/FLIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
>
<ImageView
android:id="#+id/logoinmenu"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="#string/logo"
android:src="#drawable/logoicon"
>
</ImageView>
</FrameLayout>
</RelativeLayout>
<TextView
android:id="#+id/TVUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textSize="#dimen/textViewTextSize"
android:text=""
android:layout_gravity="center"
android:textColor="#color/white"
>
</TextView>
<LinearLayout
android:id="#+id/LLAllM"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
>
<LinearLayout
android:id="#+id/LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
>
<LinearLayout
android:id="#+id/LLIVandBTG"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible"
>
<ImageView />
<Button
android:id="#+id/BTGenresRV"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="#color/float_transparent"
android:text="#string/genres"
android:textAllCaps="false"
android:textColor="#color/white"
android:gravity="start|top"
android:layout_marginStart="5dp"
>
</Button>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/RVGenresList"
android:layout_width="match_parent"
android:layout_height="150dp"
android:visibility="gone"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
Here are three more similar to "<LinearLayout android:id="#+id/LL" blocks...
</LinearLayout>
</LinearLayout>
</LinearLayout>
UPD:
I've forgotten to add that all of this handling by a public class MenuFragment extends Fragment implements View.OnTouchListener
Fragment are located in ActivityName extends AppCompatActivity
UPD2:
Partially fixed it by adding ScrollView after rootLayout and static height to recyclers.
Will see, maybe this is the best solution and I will provide full code in answer.
UPD3: This is because of wrap_content and match_parent I was not able to scroll like I need.
I have an app where I have a RecyclerView and a ListView in the same layout. The components work well individually. The RecyclerView and ListViews are completely visible and scrollable. However, when I put them on one layout parent as such:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingBottom="30dp"
android:background="#color/Cerulean">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.02" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.12" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.05" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.30" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:divider="#color/Cerulean"
android:dividerHeight="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline17" />
<ListView
android:id="#+id/listView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:divider="#color/Cerulean"
android:dividerHeight="5dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/recyclerView" />
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:src="#drawable/logo"
app:layout_constraintBottom_toTopOf="#+id/guideline17"
app:layout_constraintEnd_toStartOf="#+id/guideline14"
app:layout_constraintStart_toStartOf="#+id/guideline13"
app:layout_constraintTop_toTopOf="#+id/guideline15" />
</androidx.constraintlayout.widget.ConstraintLayout>
I just have a bunch of guidelines to help me place the logo, and I have my recyclerView and listViews after.
I used to just have the ListView, and I was able to scroll through everything. I then added my RecyclerView, which also worked well.
However, when the RecyclerView inflates and shows all its content, I am unable the scroll to my ListView anymore. I can see all the items in my RecyclerView, but as soon as I scroll through my RecyclerView, I hit the "bottom" of my activity, and I am no longer able to see my ListView.
I have also tried to add a ScrollView with nestedScrollingEnabled set to true, but that didn't help. I could only view my RecyclerView and the top row of my ListView, not to mention that the scroll experience became laggy and subpar.
What do I do in order to guarantee that I can scroll through both my RecyclerView and ListView?
It's not possible to "concatenate" the items in a RecyclerView and a ListView (that is, once you scroll through the one, it scrolls into the other) by putting one after the other. You should combine both into a single RecyclerView that contains all of the items.
Attempting to get the parent to scroll one into the other is only ever going to result in strange scrolling behavior (as you noted in your comments on the other answer).
Try this out :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
android.support.constraint.ConstraintLayout
android:id="#+id/task_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/first_list_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/second_list_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<ListView
android:id="#+id/second_list_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/first_list_view" />
I had a RecyclerView in ScrollView like this:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--other stuff-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
</LinearLayout>
<!--other stuff-->
</ScrollView>
And the RecyclerView's item is a RelativeLayout, inside of which there is an EditText and other views. The layout_height of that RelativeLayout and EditText is both wrap_content. User can input into that EditText without any limit of length/lines so that each item's height is different.
Then I found that getItemCount() in Adapter returns true value but onBindViewHolder() is called of wrong times(less than it should be), thus not enough to show all items.
I found that this will happen only if I wrote recyclerView.setNestedScrollingEnabled(false). But I cannot remove this line. Because if I did so, the RecyclerView won't scroll smoothly and is not harmonious with other views inside ScrollView and ScrollView itself.
This occurs on 6.0 but not on 4.1.
I communicated with Google at this page: https://code.google.com/p/android/issues/detail?id=213914 and he told me this is a bug fix for RecyclerView. You can visit that page so that you can understand the question and my goal better(There is a small sample project to show the problem there). I don't agree with him even now and I want to solve the problem. Please help, thank you in advance.
I found the solution myself: replace ScrollView with NestedScrollView and keep recyclerView.setNestedScrollingEnabled(false). I don't know if this is what NestedScrollView is made for but it works.
NOTICE:
NestedScrollView is not a child of ScrollView but of FrameLayout.
This solution will also bring some bugs with self-simulated adjustResize.
In my case, I replaced LineaLayout with RelativeLayout and it's solved the issue and all items have shown.
The answer is:
androidx.core.widget.NestedScrollView
In the first step, you need to create NestedScrollView element in XML:
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
// RecyclerViews should be located here
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Next, add the below attribute to recyclerView:
android:overScrollMode="never"
Then, the recyclerView will be as following:
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
Finally, the whole the layout will be something like below, you can add other materials inside LinearLayout:
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
// other materials
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Celebrate.............;)
The best solution is to keep multiple Views in a Single View / View Group and then keep that one view in the SrcollView. ie.
Format -
<ScrollView>
<Another View>
<RecyclerView>
<TextView>
<And Other Views>
</Another View>
</ScrollView>
Eg.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="any text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="any text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>
Another Eg. of ScrollView with multiple Views
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/CategoryItem"
android:textSize="20sp"
android:textColor="#000000"
/>
<TextView
android:textColor="#000000"
android:text="₹1000"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:textColor="#000000"
android:text="so\nugh\nos\nghs\nrgh\n
sghs\noug\nhro\nghreo\nhgor\ngheroh\ngr\neoh\n
og\nhrf\ndhog\n
so\nugh\nos\nghs\nrgh\nsghs\noug\nhro\n
ghreo\nhgor\ngheroh\ngr\neoh\nog\nhrf\ndhog"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
I am trying to scroll the listview inside one Linear Layout but it is not working as i want. I am attaching one image for the more explanation.
This is my Layout
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:clickable="false"
app:cardBackgroundColor="#android:color/white"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical">
<Button
android:id="#+id/findSelected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:background="#drawable/flat_selector_green"
android:text="Next"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
Image explanation
I know it s not the good approach to use the listview but i have to do this with this way.
Just remove the ScrollView from your xml code, Because ListView have their own Scroll doesn't require ScrollView.Then code will work as you want. Second List will be shown after showing every item of first ListView.
According to android docmentation
You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.
First you user card view as top parent it seem you will use it as child of list view as I guess , if my guessing is correct this not wise to use two list view as child.
Second In any case you want use two listview in same view , its recommended to separate between them with view (TextView , ... etc).
the solution
1- remove scroll as it useless.
2- add weight to your list view as wrap content in your case mean whole view.
3- recommend add view to separate between list.
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/card"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:clickable="false"
app:cardBackgroundColor="#android:color/white"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/wholeview"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="2">
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<!-- recommended to add view here -->
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/findSelected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:text="Next"
android:textColor="#android:color/white"
/>
</LinearLayout>
</RelativeLayout>