0

我设法让按钮一直可见,这很难看。

根据新材料设计,我们应该使用 RecyclerView 而不是 ListView,所以我想知道如何让按钮仅在用户滚动到列表末尾时出现,但始终不可见。

此外,由于一些未解决的问题 72217,回收站视图无法在工作室中呈现。所以我看不到元素按钮和回收站视图如何相互对齐

呸呸呸

主活动.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"/>

第二个问题:我只能看到一个 FORWARD 按钮,而不是 2 个按钮,即使我在上面的代码中声明了这两个按钮并为两个向前向后按钮都使用了属性alignParentright = true 和 alignParentLeft=true 。

4

1 回答 1

1
  1. RecyclerView 加号按钮

我看到了两种不同的解决方案,第一个是将 RecyclerView 和按钮放在 ScrollView 内,禁用 RecyclerView 垂直滚动,滚动将由 ScrollView 管理。就像下面的代码:

<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>

第二个选项是在回收器视图的滚动位于底部时使用 setVisibility,应该可以帮助您对该选项进行排序。

  1. 只看到一个按钮

原因是因为您在两个按钮中都将宽度设置为 match_parent,一个隐藏另一个,如果您将宽度设置为 wrap_content,它将在那里。

于 2015-03-26T09:38:24.063 回答