BottomSheetLayout
BottomSheetLayout copied to clipboard
Views with selectors doesnt work
I am adding background selectors in the items inside bottomsheetLayout but it seems that doesnt work.
IDK why.
this is the layout:
<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="match_parent"
android:background="@color/background_menu"
android:orientation="vertical">
<LinearLayout
android:id="@+id/llToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/mako"
android:clickable="true"
android:gravity="center"
android:padding="5dp">
<ImageView
android:id="@+id/ivToggle"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="15dp"
android:src="@drawable/down" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:id="@+id/clLive"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/selector_bg_abbey"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivLive"
android:layout_width="24.7dp"
android:layout_height="24.7dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:clickable="false"
android:focusable="false"
android:src="@drawable/ic_live"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.15"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvLive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_lg"
android:clickable="false"
android:focusable="false"
android:text="@string/menu_live"
android:textColor="@color/cyan"
android:textSize="20.7sp"
app:layout_constraintBottom_toBottomOf="@+id/ivLive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/ivLive"
app:layout_constraintTop_toTopOf="@+id/ivLive" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/mako"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/clVideoHistory"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/selector_bg_abbey"
android:clickable="true"
android:focusable="true">
<ImageView
android:id="@+id/ivVideoHistory"
android:layout_width="24.7dp"
android:layout_height="24.7dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:clickable="false"
android:focusable="false"
android:src="@drawable/ic_video_history_off"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.15"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvVideoHistory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_lg"
android:clickable="false"
android:focusable="false"
android:text="@string/menu_video_history"
android:textColor="@color/white"
android:textSize="20.7sp"
app:layout_constraintBottom_toBottomOf="@+id/ivVideoHistory"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/ivVideoHistory"
app:layout_constraintTop_toTopOf="@+id/ivVideoHistory" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/mako"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</LinearLayout>
This is the selector (selector_bg_abbey.xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/black_25percent" android:state_pressed="true" />
<item android:drawable="@color/abbey" />
</selector>
The thing is that no one of the ConstraintLsyout do nothing with that background.
There are a few different test to try to understand this behavior.
At the moment, the only touch event I can pass to the views inside the layout is the click, to be able to drag the view from anywhere I need to intercept every touch event and if I detect a click I pass it back to the view. For the moment the only way yo be able to perform any touch on a view is to create another view at the same level as the layout and animate this view alongside the layout (using the setOnProgressListener method)