【问题标题】:Material Design pagination guidelines in AndroidAndroid 中的 Material Design 分页指南
【发布时间】:2016-01-12 11:22:06
【问题描述】:

我有一个包含超过 200 行数据的 RecycleView,我想实现分页机制。

使用 Material Design 最佳实践来实现这一点的正确方法是什么?谷歌似乎忘记了这个重要因素。

你能指导我一些代码或设计的例子吗?

【问题讨论】:

  • 你是从服务器获取的,对吧?
  • 分析使用分页的 Google 应用(Google+、报亭)并了解它们是如何实现的。
  • 是的,数据来自服务器。向下滚动数据直到找到您喜欢的数据只是糟糕的用户体验,这就是我正在寻找分页解决方案的原因。
  • here

标签: android pagination material-design


【解决方案1】:

您可以从 Google 的“Data Tables”中获取一些分页材料设计指南:

下面是对应的xml分页布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
  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 = "56dp"
  android:background = "@color/white"
  android:gravity = "center_vertical|end"
  android:orientation = "vertical">

  <LinearLayout
    android:layout_width = "match_parent"
    android:layout_height = "match_parent"
    android:layout_marginBottom = "1dp"
    android:gravity = "center_vertical|end"
    android:orientation = "horizontal">

    <TextView
      android:layout_width = "wrap_content"
      android:layout_height = "wrap_content"
      android:layout_marginEnd = "40dp"
      android:text = "@string/rows_per_page"
      android:textColor = "@color/discreet_dark"
      android:textSize = "12sp"/>

    <TextView
      android:id = "@+id/paginationSize"
      android:layout_width = "24dp"
      android:layout_height = "wrap_content"
      android:text = "50"
      android:textAlignment = "textEnd"
      android:textColor = "@color/discreet_dark"
      android:textSize = "12sp"/>

    <ImageView
      android:id = "@+id/paginationDropdown"
      android:layout_width = "24dp"
      android:layout_height = "24dp"
      android:layout_marginEnd = "32dp"
      android:contentDescription = "@string/dropdown"
      app:srcCompat = "@drawable/dropdown_discreet_dark"
      tools:src = "@drawable/dropdown_discreet_dark"/>

    <TextView
      android:id = "@+id/paginationDisplayed"
      android:layout_width = "wrap_content"
      android:layout_height = "wrap_content"
      android:layout_marginEnd = "32dp"
      android:text = "1-50 из 100"
      android:textAlignment = "textEnd"
      android:textColor = "@color/discreet_dark"
      android:textSize = "12sp"/>

    <ImageView
      android:id = "@+id/paginationPrevious"
      android:layout_width = "24dp"
      android:layout_height = "24dp"
      android:layout_marginEnd = "24dp"
      android:contentDescription = "@string/pagination_previous"
      app:srcCompat = "@drawable/pagination_previous_discreet_dark"
      tools:src = "@drawable/pagination_previous_discreet_dark"/>

    <ImageView
      android:id = "@+id/paginationNext"
      android:layout_width = "24dp"
      android:layout_height = "24dp"
      android:layout_marginEnd = "14dp"
      android:contentDescription = "@string/pagination_next"
      app:srcCompat = "@drawable/pagination_next_discreet_dark"
      tools:src = "@drawable/pagination_next_discreet_dark"/>

  </LinearLayout>

  <View
    android:layout_width = "match_parent"
    android:layout_height = "1dp"
    android:layout_gravity = "bottom"
    android:layout_marginBottom="1dp"
    android:background = "@color/discreet_dark"/>

</LinearLayout>

【讨论】:

    猜你喜欢
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 2018-04-24
    相关资源
    最近更新 更多