如何在视图寻呼机内添加内容。我看不到内容

时间:2016-11-24 18:19:53

标签: android android-layout android-fragments android-viewpager

我想制作个人资料视图(见下文)。 enter image description here

目前我有个人资料照片和两个标签(日记和朋友)的视图。

这是我的活动布局,其中包含两个标签。     

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/base_background"
        android:id="@+id/app_bar">

        <include layout="@layout/dog_profile" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/dog_header"
            android:background="@color/base_background"
            app:tabGravity="fill"
            app:tabMode="fixed" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primary"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</RelativeLayout>

这是我的日记片段,但我无法在日记片段中看到任何内容。它可能在左上角。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_below="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:background="@color/accent"
        android:layout_alignParentBottom="true"/>

    <TextView
        android:id="@+id/tv_no_memories"
        style="@style/NoItemsStyle"
        android:text="@string/no_memories" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        style="@style/FabStyle"/>
</RelativeLayout>

我不知道应该改变什么,我可以看到片段内的内容。

在我的活动中,我正在设置像这样的视图寻呼机

  ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFragment(new DogDiaryFragment(), tab1);
    adapter.addFragment(new DogFriendsFragment(), tab2);
    viewPager.setAdapter(adapter);

tabLayout.setupWithViewPager(viewPager);

感谢您的任何建议

1 个答案:

答案 0 :(得分:0)

我通过在活动xml中将垂直方向的相对布局更改为线性布局来解决。