自定义视图未完全显示在活动中

时间:2017-04-29 10:56:29

标签: android android-layout android-viewpager android-custom-view

我正在尝试从https://github.com/armcha/Space-Navigation-View

显示“Spaces-Navigation-View”

我面临的问题是视图完全出现在简单的活动中,但不包含在包含协调器布局的主要活动中。

这是我的主要活动的xml,结果在

下面
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
android:id="@+id/main_content"

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"                                                 
android:layout_width="match_parent"                                                 
android:layout_height="match_parent"                                                 
android:animateLayoutChanges="true"                                                  
android:fitsSystemWindows="true"                                                 
tools:context="com.rvnd.bookshare.Strt">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:animateLayoutChanges="false"
    android:background="@color/background"
    android:paddingTop="@dimen/appbar_padding_top"
    app:elevation="0dp"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/transparent"

        app:popupTheme="@style/AppTheme.PopupOverlay">
        <TextView
            android:text="Book Share"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="cursive"
            android:textSize="27sp"
            android:textColor="@color/text"/>


    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"

 app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
        />
    <TextView
        android:id="@+id/status"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:elevation="5dp"
        android:textColor="#000000"
        android:background="#FFD54F"
        android:gravity="center"
        android:padding="5dp"
        android:layout_gravity="top|center"
        android:visibility="gone"
        android:text="Syncing..."
        android:textAppearance="?android:attr/textAppearanceMedium"/>

</android.support.design.widget.AppBarLayout>



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

<com.luseen.spacenavigation.SpaceNavigationView
    android:id="@+id/space"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:space_background_color="@color/colorPrimary"
    android:layout_gravity="bottom"
    android:background="@color/colorPrimary"



 app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>

        />
<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="@dimen/fab_margin"
    android:visibility="gone"
    app:srcCompat="@drawable/booky"/>

</android.support.design.widget.CoordinatorLayout>

这是结果 enter image description here

另一方面,如果我在不同的简单活动中使用相同的视图,则视图会正确呈现

以下是代码及其下方,它实际上应该是什么样子

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


 android:id="@+id/activity_history"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.rvnd.bookshare.History"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:gravity="center"
    android:background="@color/skyblue"

    android:layout_height="40dp">


<TextView
    android:text="All your book transfers are recorded here..."
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:id="@+id/status"
    android:textColor="#ffffff"
    android:gravity="center"
    android:layout_weight="1"
    android:textSize="13sp"/>

    <Button
        android:text="Clear history"
        android:layout_height="match_parent"
        android:id="@+id/clear"
        android:textAllCaps="false"

        android:layout_width="98dp"
        android:textSize="12sp"/>
</LinearLayout>

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/rec"/>


<com.luseen.spacenavigation.SpaceNavigationView
    android:id="@+id/space"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:space_background_color="@color/colorPrimary"
    android:background="@color/colorPrimary"
    android:layout_gravity="bottom"



app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>
    </LinearLayout>

结果如下: enter image description here

我已经尝试了一切,它只是没有正确显示,请帮忙! 感谢

0 个答案:

没有答案