Reputation: 24500
I have managed to make button visible all the time, this is ugly.
According to new material design we should use RecyclerView not ListView, so i wonder how to make buttons only appear when user scrolls to the end of the list, but not visible all the time.
In addition, recycler view can't be rendered in studio because of some open issue 72217. So I can't see how elements buttons and recycler view align with each other
mainActivity.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include android:id="@+id/app_bar" layout="@layout/toolbar"/>
<ImageButton
android:id="@+id/button_previous"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:minHeight="25dp"
android:minWidth="70dp"
android:src="@android:drawable/ic_media_previous"/>
<ImageButton
android:id="@+id/button_next"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:minHeight="25dp"
android:minWidth="70dp"
android:src="@android:drawable/ic_media_next"/>
<view
android:id="@+id/recycler_view"
android:layout_below="@id/app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="android.support.v7.widget.RecyclerView"/>
2nd issue: I can only see one FORWARD button, not 2 buttons, even though I declared both in the code above and used attribute alignParentright = true and alignParentLeft=true for both forward backward buttons.
Upvotes: 0
Views: 919
Reputation: 154
I see two different solutions for that, first one is you place the RecyclerView and the button inside of a ScrollView disabling the RecyclerView vertical scroll and the scroll will be managed by the ScrollView. It would be like the code below:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/partner_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<view
android:id="@+id/recycler_view"
android:layout_below="@id/app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="android.support.v7.widget.RecyclerView"/>
<ImageButton
android:id="@+id/button_next"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:minHeight="25dp"
android:minWidth="70dp"
android:src="@android:drawable/ic_media_next"/>
</LinearLayout>
</ScrollView>
The second option would be to use setVisibility once the scroll of the recycler view is at thbe bottom, this should help you to sort this option.
The reason is because you have in both buttons width as match_parent, one is hidden the other one, if you set the width as wrap_content it will be there.
Upvotes: 1