我正在开发一个主要活动包含SwipeView布局的应用程序。
该活动由2000多个页面组成,这些页面由文本单独填充,这些文本是短篇的。
我想在这些页面上添加一个浮动操作按钮,点击后会将FACT标记为收藏夹,用户可以在以后查看。
如何实现这一点,而无需单独为所有页面添加按钮(这将是不切实际和荒谬的)。
答案 0 :(得分:1)
您可以将按钮放在包含ViewPager的Activity或片段上,而不是放在每个ViewPager的适配器
上<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/vpMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:layout_margin="15dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/btn_favorite"/>
</RelativeLayout>