我想在我的片段中添加持久的底页。我有一个基本的片段代码和一个底部工作表布局。有人可以帮我将底片集成到片段中吗?
感谢您的宝贵时间,不胜感激。
这是我的片段:
package app.com.navact;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
public class TabFragment1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_tab_fragment1, container, false);
}
}
这是我持久的底部工作表布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mayojava.sample.bottomsheetdemo.MainActivity">
<!-- main content layout-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
......
</RelativeLayout>
<!-- bottom sheet layout -->
<RelativeLayout
android:id="@+id/linear_layout_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="220dp"
app:behavior_peekHeight="80dp"
app:behavior_hideable="true"
app:layout_behavior="hellooooz"
android:elevation="20sp"
android:background="@color/colorAccent">
<TextView
android:id="@+id/text_view_sheet_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="kalle kalle "
android:textSize="16sp"
android:padding="@dimen/activity_vertical_margin"/>
<TextView
android:id="@+id/text_view_more_content"
android:text="helllo"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_sheet_title"
android:paddingLeft="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_vertical_margin"/>
<Button
android:text="balle balle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_below="@+id/text_view_more_content"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
最佳答案
在您的Fragment布局xml中,将底部工作表的RelativeLayout的布局行为更改为:
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"