Эффект ряби не виден в полном ряду - PullRequest
1 голос
/ 06 января 2020

У меня есть RecyclerView со строкой, которая имеет галочку и значок перетаскивания (переупорядочить) справа. Как и в официальном видео о дизайне материалов , я хочу, чтобы эффект ряби был на всем протяжении. Но когда я расширяю ImageView, CheckBox больше не активируется. Это вообще возможно?

   <FrameLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:orientation="horizontal"
        android:background="@android:color/white"
        android:paddingLeft="@dimen/small_margin"
        android:paddingRight="@dimen/small_margin">

        <CheckBox
            android:id="@+id/checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start|center_vertical"
            android:checked="@{safeUnbox(viewModel.isEnabled), default=false}"
            android:padding="@dimen/small_margin"
            android:text="@={viewModel.abbreviation}"
            android:textAppearance="@style/TextAppearance.Compat.Notification.Title"
            tools:text="Bijbelvertaling" />

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <ImageView
            android:id="@+id/dragger"
            android:layout_width="40dp"
            android:background="?android:attr/selectableItemBackground"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|end"
            android:scaleType="center"
            android:src="@drawable/ic_drag_handle_24px"
            android:contentDescription="Drag and drop icon" />
    </FrameLayout>

enter image description here

1 Ответ

2 голосов
/ 06 января 2020

Вместо FrameLayout используйте RelativeLayout, как показано ниже, и примените эффект ряби android:foreground="?android:attr/selectableItemBackground" к root макету.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layout"
    android:clickable="true"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:orientation="horizontal"
    android:foreground="?android:attr/selectableItemBackground"
    android:background="@android:color/white"
    android:paddingLeft="@dimen/small_margin"
    android:paddingRight="@dimen/small_margin">

    <CheckBox
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:checked="@{safeUnbox(viewModel.isEnabled), default=false}"
        android:padding="@dimen/small_margin"
        android:text="@={viewModel.abbreviation}"
        android:textAppearance="@style/TextAppearance.Compat.Notification.Title"
        tools:text="Bijbelvertaling" />

    <ImageView
        android:id="@+id/dragger"
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:scaleType="center"
        android:src="@drawable/ic_drag_handle_24px"
        android:contentDescription="Drag and drop icon" />

</RelativeLayout>

Вывод: enter image description here

...