c# - How to disable all touches for a Layout in Android -
i trying implement bottom sheet in xamarin.android
, want disable touches on not bottom sheet (i.e. main layout), when bottom sheet active.
main.axml:
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/main_layout"> <include android:id="@+id/toolbar" layout="@layout/toolbar" /> <!-- main layou --> <framelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/main_content" android:paddingleft="16dp" android:paddingright="16dp" > <button android:id="@+id/btn_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/logout" android:layout_gravity="center" /> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margin="16dp" android:clickable="true" android:src="@drawable/ic_plus" /> </framelayout> <framelayout android:id="@+id/tint" android:background="#000000" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- bottom sheet --> <framelayout android:id="@+id/bottom_fragment_container" android:layout_width="match_parent" android:layout_height="160dp" android:background="#e0e0e0" android:layout_gravity="bottom" android:elevation="16dp" android:translationy="160dp" />
i tried iterating on children , disabling them, changes appearance of button , want avoid that. tried setting enabled
property of layout false
, button still touchable.
i think need somehow intercept touches before reach button (and else there later), don't know how that. intercepting touches implement hiding of bottom sheet after touches.
create transparent relativelayout
covers entire screen , use android:clickable="true"
property in make sure intercepts click events.
then add android:layout_alignparentbottom
bottom sheet , put inside newly created relativelayout
. way it'll appear @ bottom , else won't clickable.
<framelayout> <!-- main layout --> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0000" android:clickable="true"> <framelayout android:id="@+id/bottom_fragment_container" android:layout_width="match_parent" android:layout_height="160dp" android:background="#e0e0e0" android:layout_alignparentbottom="true" android:elevation="16dp" android:translationy="160dp" /> </relativelayout> </framelayout>
Comments
Post a Comment