sách gpt4 ăn đã đi

java - 如何让 float Action 按钮消耗点击事件?

In lại 作者:太空狗 更新时间:2023-10-29 16:36:46 25 4
mua khóa gpt4 giày nike

我目前正在我正在制作的应用程序中设置一个 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/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress