我正在使用:
> com.android.support:appcompat-v7
> com.android.support:support-v4
> com.android.support:recyclerview-v7
> com.android.support:design
> https://github.com/umano/AndroidSlidingUpPanel
> https://github.com/serso/android-linear-layout-manager
> https://github.com/daimajia/AndroidSwipeLayout
> https://github.com/tmiyamon/gradle-mdicons
我最终使用了支持库的一部分,但这个特定的应用程序只有5.0,所以我的代码中可能只有一些Lollipop的东西.
这是RecyclerView中列表项的布局:
- <com.daimajia.swipe.SwipeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="right">
- <RelativeLayout
- android:layout_width="42dp"
- android:layout_height="match_parent"
- android:background="?android:selectableItemBackground"
- android:clickable="true"
- android:focusable="true">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_centerHorizontal="true"
- android:src="@drawable/ic_delete_black_24dp"/>
- </RelativeLayout>
- <RelativeLayout
- android:id="@+id/surfaceView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/ripple_floating"
- android:clickable="true"
- android:focusable="true"
- android:minHeight="48dp"
- android:paddingEnd="16dp"
- android:paddingStart="16dp"
- android:elevation="2dp">
- <TextView
- android:id="@+id/name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:ellipsize="end"
- android:singleLine="true"
- android:text="..."/>
- </RelativeLayout>
- </com.daimajia.swipe.SwipeLayout>
这是目前的结果.
剩下的问题是海拔阴影和分隔线.
正如您在图像中可以看到的,在列表项目的两侧有一些合理的阴影.然而,物品底部没有海拔阴影,所以当一个物品被揭露时,没有阴影显示在透明区域之上.
第二个问题是分隔线.我有一个单项目列表,没有图标/图像,所以正确的设计是使用分隔符的项目.
然而,我不能使用serso / android-linear-layout-manager中的DividerItemDecoration,因为它没有被集成到滑块中,当两个相邻的项目被滑动时,会发生这种情况.
有谁知道任何可绘制,属性或库,我应该用来将这些列表项作为具有海拔阴影和边框的材料表样式?
解决方法
对于阴影/海拔看起来,您可以使用卡片视图与普通的技巧,使它们比屏幕宽度(“全宽卡”)稍宽.
例如:
- <android.support.v7.widget.CardView
- android:layout_width="match_parent"
- android:layout_height="72dp"
- android:layout_marginLeft="@dimen/card_margin_horizontal"
- android:layout_marginRight="@dimen/card_margin_horizontal"
- app:cardCornerRadius="0dp"
- app:cardElevation="4dp">
在值/ dimensions.xml中:
- <dimen name="card_margin_horizontal">-3dp</dimen>
在值-v21 / dimensional.xml中
- <dimen name="card_margin_horizontal">0dp</dimen>
分频器
而且,您可能不需要更改分隔线,它可能看起来不错.否则,尝试将分隔符添加到视图本身(顶视图或控制它的可见性).它可以只是一个高度为1dp和width match_parent的视图,backgroundColor设置为一些深灰色(或系统分隔符drawable(R.attr.listDivider)).