Tôi có một FAB nằm ở giữa hai bố cục. Sử dụng lợi nhuận tiêu cực cùng với android:clipChildren
và android:clipToPadding
cả thiết lập để sai tôi có thể sản xuất ngạc đặt ít nút này:Nút bị cắt không nhận được đầu vào cảm ứng
Bây giờ, vấn đề là nửa dưới của FAB không nhận được liên lạc đầu vào hoặc nói cách khác: không thể nhấp được. Tôi đã cố gắng chơi xung quanh với android:elevation
đảm bảo rằng nó nằm trong giá trị Z cao nhất có thể nhưng vấn đề vẫn còn. Nửa đầu, trong khi đó, chỉ hoạt động tốt.
tôi là kinda khó khăn về vấn đề này, bất cứ ai ở đây có thể giúp tôi phải làm gì? Dưới đây là XML
của tôi để bố trí, trong trường hợp bạn cần.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/rl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<id.ridsatrio.taggr.widgets.ObservableScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/sv_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:clipChildren="false"
android:clipToPadding="false"
android:focusable="true"
android:focusableInTouchMode="true">
<id.ridsatrio.taggr.widgets.SquaredImageView
android:id="@+id/iv_details_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="Album Art Image"
android:elevation="@dimen/elevation_none"
android:focusable="true"
android:scaleType="centerCrop"
android:src="@drawable/def_album_art" />
<View
android:id="@+id/v_anchor"
android:layout_width="match_parent"
android:layout_height="@dimen/details_header_height"
android:layout_below="@+id/iv_details_header"
android:elevation="@dimen/elevation_low" />
<LinearLayout
android:id="@+id/ll_track_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/v_anchor"
android:orientation="vertical">
...
</LinearLayout>
<View
android:id="@+id/v_divider"
android:layout_width="match_parent"
android:layout_height="@dimen/details_section_divider_height"
android:layout_below="@id/ll_track_fields"
android:layout_marginLeft="@dimen/details_section_divider_margin_start"
android:layout_marginTop="@dimen/item_horizontal_margin_xlarge"
android:background="@color/dividers_light" />
<LinearLayout
android:id="@+id/ll_album_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/v_divider"
android:orientation="vertical">
...
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_header"
android:layout_width="match_parent"
android:layout_height="@dimen/details_header_height"
android:layout_gravity="center_horizontal"
android:background="@color/primary"
android:clipChildren="false"
android:clipToPadding="false"
android:elevation="@dimen/elevation_low">
...
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="@dimen/details_header_fab_margin_bottom"
android:layout_marginLeft="@dimen/details_header_fab_margin_start"
android:background="?android:attr/selectableItemBackground"
android:elevation="@dimen/elevation_medium"
android:src="@drawable/ic_action_down"
fab:fab_colorNormal="@color/primary_dark"
fab:fab_colorPressed="@color/primary"
fab:fab_type="mini" />
</RelativeLayout>
</RelativeLayout>
</id.ridsatrio.taggr.widgets.ObservableScrollView>
...
</RelativeLayout>
Mọi trợ giúp sẽ được đánh giá cao. Nếu bạn cần thêm chi tiết về điều này, tôi cũng vui mừng cung cấp thêm.
Cảm ơn trước!
Sửa: Nhờ MoshErsan, tôi cuối cùng có thể làm việc này. Dưới đây là tôi XML
làm việc trong trường hợp bất cứ ai gặp phải vấn đề tương tự như tôi:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/rl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<id.ridsatrio.taggr.widgets.ObservableScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/sv_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:clipChildren="false"
android:clipToPadding="false"
android:focusable="true"
android:focusableInTouchMode="true">
<id.ridsatrio.taggr.widgets.SquaredImageView
android:id="@+id/iv_details_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="Album Art Image"
android:elevation="@dimen/elevation_none"
android:focusable="true"
android:scaleType="centerCrop"
android:src="@drawable/def_album_art" />
<View
android:id="@+id/v_anchor"
android:layout_width="match_parent"
android:layout_height="@dimen/details_header_height"
android:layout_below="@+id/iv_details_header"
android:elevation="@dimen/elevation_low" />
<LinearLayout
android:id="@+id/ll_track_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/v_anchor"
android:orientation="vertical">
...
</LinearLayout>
<View
android:id="@+id/v_divider"
android:layout_width="match_parent"
android:layout_height="@dimen/details_section_divider_height"
android:layout_below="@id/ll_track_fields"
android:layout_marginLeft="@dimen/details_section_divider_margin_start"
android:layout_marginTop="@dimen/item_horizontal_margin_xlarge"
android:background="@color/dividers_light" />
<LinearLayout
android:id="@+id/ll_album_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/v_divider"
android:orientation="vertical">
...
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_header"
android:layout_width="match_parent"
android:layout_height="@dimen/details_header_height"
android:layout_gravity="center_horizontal"
android:background="@color/primary"
android:clipChildren="false"
android:clipToPadding="false"
android:elevation="@dimen/elevation_low">
...
</RelativeLayout>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/rl_header"
android:layout_alignLeft="@+id/rl_header"
android:layout_marginBottom="@dimen/details_header_fab_margin_bottom"
android:layout_marginLeft="@dimen/details_header_fab_margin_start"
android:background="?android:attr/selectableItemBackground"
android:elevation="@dimen/elevation_medium"
android:src="@drawable/ic_action_down"
fab:fab_colorNormal="@color/primary_dark"
fab:fab_colorPressed="@color/primary"
fab:fab_type="mini" />
</RelativeLayout>
</id.ridsatrio.taggr.widgets.ObservableScrollView>
...
</RelativeLayout>
Nếu có một điều để học hỏi từ đây nó này: Thiết android:clipChilden
-false
sẽ cho phép nói Xem để vẽ bên ngoài đó là bố trí mẹ NHƯNG bất kỳ liên lạc đầu vào sẽ vẫn bị giới hạn ở ranh giới của cha mẹ.
bạn có thể di chuyển FAB để xem mới nhất trong bố cục gốc không ?? Tôi có nghĩa là tăng chỉ số Z của nó –
@ MoshErsan, điều đó không có nghĩa là thêm công việc để định vị? – ridsatrio
Tôi nghĩ rằng vấn đề là ngay cả khi bạn đã đưa FAB vào trước bố trí bên cạnh nó, vẫn bố trí tiêu thụ sự kiện cảm ứng, vì vậy tôi vẫn khuyên bạn nên sử dụng FrameLayout làm bố cục gốc và đặt FAB như lần xem cuối cùng trong số –