所以,我以某种方式解决了这个问题。我的activity_main.xml
样子是这样的。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_background"
android:orientation="vertical"
>
<fragment
android:id="@+id/title_layout"
android:name="com.kalpnik.vrdevotee.fragment.MainTitleFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_weight="1"
/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/title_layout"
android:layout_weight="1"
tools:deviceIds="tv"
/>
</LinearLayout>
在FrameLayout
我将加载一个从 扩展的片段BrowseFragment
,所以这给了我必要的行。
在顶部,我正在加载MainTitleFragment
扩展,Fragment
布局如下所示。
片段主标题.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#000000"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/icon_background"
android:orientation="vertical"
android:paddingTop="16dp"
>
<TextView
android:id="@+id/title_content_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
tools:text=""
android:textColor="@color/colorPrimaryDark"
android:textSize="28sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/title_content_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:ellipsize="end"
android:text=""
android:textSize="15sp"
/>
</LinearLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/title_content_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<View
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="@drawable/transparent_bg"
/>
<View
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:background="@drawable/transparent_bg_bottom"
/>
</FrameLayout>
</LinearLayout>
这对我有用。希望这可以帮助。