Bài viết phổ biến của tác giả
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我目前正在我正在制作的应用程序中设置一个 float 操作按钮。我的问题是,当我单击按钮时,按钮后面的 ListView 也接收到单击事件。我需要让按钮消耗整个点击事件。
我正在使用这个库来创建按钮:https://github.com/FaizMalkani/FloatingActionButton
如果有人能为我指明如何实现这一目标的正确方向,我将不胜感激。我在下面包含了我正在使用的 xml 布局。
谢谢科里:)
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="match_parent">
<>
android:id="@+id/viewPager"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="0px"
android:layout_weight="1">
<>
android:id="@+id/fabbutton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="bottom|right"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
app:colour="@color/holo_red_light"
app:drawable="@drawable/ic_content_new"
/>
câu trả lời hay nhất
我不知道 FloatingActionButton 的实现细节,但是你可以设置一个 TouchListener 并使用 onTouch 方法返回 true 的事件。像这样:
mFloatingActionButton.setOnTouchListener(new OnTouchListener() {
@Ghi đè
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){
// Do what you want
trả về giá trị đúng;
}
return true; // consume the event
}
});
关于java - 如何让 float Action 按钮消耗点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26931540/
Tôi là một lập trình viên xuất sắc, rất giỏi!