Fis*_*fon 2 java android material-design floating-action-button
我目前正在我的应用程序中设置一个浮动操作按钮.我的问题是当我点击按钮时,按钮后面的列表视图也会收到点击事件.我需要这样做,以便按钮消耗整个点击事件.
我正在使用此库创建按钮:https://github.com/FaizMalkani/FloatingActionButton
如果有人能指出我如何实现这一目标的正确方向,我将不胜感激.我已经包含了我在下面使用的xml布局.
谢谢科里:)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
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"
/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我不知道FloatingActionButton的实现细节,但您可以设置TouchListener并使用从onTouch方法返回true的事件.像这样的东西:
mFloatingActionButton.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){
// Do what you want
return true;
}
return true; // consume the event
}
});
Run Code Online (Sandbox Code Playgroud)