So I'm trying to make something similar to how snapchat does the options menu where you slide down and you can still see the camera in the background. I won't post all the code, but I've debugged what it is that's causing a problem. I'm a noob to android dev, but I've done some java programming before.
This is my xml
<me.dontenvy.videotest.MainMenu xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:id="@+id/main_menu">
<!-- this is for the camera -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/camera_container">
<TextureView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/texture"
android:animateLayoutChanges="true"/>
</RelativeLayout>
<!-- this is for the overlay menu -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slide_menu"
android:animateLayoutChanges="true"
android:background="@drawable/transparent_background">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/clear_background"
android:layout_alignParentBottom="true"
android:id="@+id/slide_button"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="@dimen/circle_nav_button_diameter"
android:layout_height="@dimen/circle_nav_button_diameter"
android:background="@drawable/circle_button"
android:backgroundTint="#050"
android:id="@+id/take_image_nav_button"/>
</LinearLayout>
</RelativeLayout>
</me.dontenvy.videotest.MainMenu>
I add the onClick listener within my MainMenu.java class which extends RelativeLayout. Here is a gist with the rest of the code https://gist.github.com/colmex/1bd19dd2cfc400b2f870
The issue is that when the @id/take_image_nav_button is in the LinearLayout, the onClick action doesn't work, when I take it out of it's LinearLayout, the onClick action does work. It feels like the LinearLayout is somehow blocking the click. I've tried a lot of things I've found on stackoverflow and other googling, but nothing seems to fix it.
On the LinearLayout parent to the button you have set android:clickable="false"
, but this makes everything inside it unclickable too. To fix it, change false
to true
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:clickable="true"> // Change here to true, like this
Or simply remove this attribute.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.