我已经实现了一个导航抽屉。在导航的FrameLayout抽屉中,我添加了一个包含2个ViewPagers的片段,每个片段恰好占据半个屏幕。现在,我想在这两个视图寻呼机的交界处添加一个FAB按钮,如下所示。
在我的例子中,两个视图寻呼机恰好占据了半个屏幕,这与图像中显示的略有不同。有没有人能帮我把车开到路口。
包含两个视图寻呼机的片段代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/shirt_section"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" />
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pant_section"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" />
</LinearLayout>
发布于 2015-07-08 07:27:41
您可以将线性布局封装到FrameLayout中,然后添加按钮,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</LinearLayout>
<ImageButton
android:layout_gravity="center_vertical|right"
...
/>
</FrameLayout>
https://stackoverflow.com/questions/31285428
复制