你好,朋友们,我想在我的应用程序中制作像 YouTube 一样的定制滑动抽屉

enter image description here

当用户单击任何项​​目时,它应该像上面的图片一样显示,我突出显示,所以知道如何实现这一点吗?

有帮助吗?

解决方案

昨天我遇到了同样的问题

but this examples highlight selector in whole listbackground but i also want red color indicator at starting which is mention

您需要创建两个选择器。1.对于整个项目 2。对于那个红色部分

为此,在左侧的列表项中放置一个视图并为其创建一个选择器。

然后使用以下代码。这里 android:duplicateParentState="true" 为你工作。当此属性设置为true时,该视图从其直接父级而不是从本身中获取可绘制的状态(聚焦,按压等)。

<TextView
    android:layout_width="3dp"
    android:layout_height="match_parent"
    android:duplicateParentState="true"
    android:background="@drawable/selector_for_red" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top