The*_*ter 0 android android-scrollview floating-action-button
我有一个CoordinatorLayout和它里面,两个FloatingActionButton和它们下面一个ScrollView.
问题是即使我可以FloatingActionButtons在屏幕上看到我也无法点击它们.我怀疑那是因为所有onTouch事件都是在处理ScrollView
这是我的布局xml(这可能非常糟糕,所以欢迎任何提示):
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Note: that 80dp padding is:
main_padding + fab_size + 8dp = 80dp
16dp + 56dp + 8dp = 80dp
and it was the only way I could think to add padding
between my FABs
I tried to use app:layout_anchor but my 2
FABs had no padding between them... -->
<android.support.design.widget.FloatingActionButton
style="@style/RefreshFab"
android:id="@+id/fab_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="80dp"
android:layout_marginEnd="16dp"
app:fabSize="normal"
app:pressedTranslationZ="12dp"/>
<android.support.design.widget.FloatingActionButton
style="@style/SendFab"
android:id="@+id/fab_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="bottom|end"
app:fabSize="normal"
app:elevation="6dp"
app:pressedTranslationZ="12dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Toolbar -->
<include
layout="@layout/view_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Much stuff here, text views, spinners etc.. -->
</LinearLayout>
</ScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
问题是因为每个项目在CoordinatorLayout中的布局顺序与它在xml中编写的顺序相同.按照这个逻辑,每个FloatingActionButtons都放在屏幕上,然后放在它们之上的LinearLayout,所以我希望LinearLayout可以覆盖这个点击.
重新排列XML以将FloatingActionButtons放在最后,这样它们就可以说是"在顶部"了.然后他们会很好地检测你的点击听众.
我认为问题将持续存在,因为每个FloatingActionButton都包含在具有match_parent维度的FrameLayout内.我不相信你需要这些FrameLayouts,但你可以简单地将FloatingActionButtons放在CoordinatorLayout中.
| 归档时间: |
|
| 查看次数: |
2933 次 |
| 最近记录: |