2017-04-19 101 views
0

我有下面的XML,我要放置recyclerview上方和下方recyclerview一個文本視圖,但是它的顯示錯誤添加一個TextView下面recyclerview抽屜佈局

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 



    <android.support.v4.widget.DrawerLayout  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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

     <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerview1" 
     android:scrollbars="vertical" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/testv" 
     android:paddingTop="60dp"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Text" 
     android:id="@+id/textView3" 
     android:layout_below="@+id/recyclerview1" 
     android:background="@android:color/holo_green_light" 
     /> 



    <include 
     android:id="@+id/appbar" 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 



</android.support.v4.widget.DrawerLayout> 

    </LinearLayout> 

更新

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" 
tools:context="com.example.mohamadmouazen.lebgame.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    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="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

<!--<include layout="@layout/content_main" /> --> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    android:src="@android:drawable/ic_dialog_email" /> 

+0

顯示完整的XML代碼,請。 – tahsinRupam

+0

與我們分享您的所有佈局。另外一張照片,看起來會有幫助。 –

+0

你能附上一張圖片嗎? –

回答

1

我想將文本視圖放在回收站視圖的上方,並在回收站的下方 鑑於

試試這個佈局:

使用Linearlayout與垂直方向內的DrawerLayout

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="true" 
    android:focusableInTouchMode="true"> 

    <android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/overview_coordinator_layout" 
     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:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimaryDark" 
       app:layout_scrollFlags="enterAlways|scroll" /> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginTop="?attr/actionBarSize" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/textViewAbove" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:background="@android:color/holo_green_light" 
       android:text="New Text above" /> 


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

      <TextView 
       android:id="@+id/textViewBelow" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@android:color/holo_green_light" 
       android:text="New Text Below" /> 

     </LinearLayout> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/overview_floating_action_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="16dp" 
      android:clickable="true" 
      android:src="@mipmap/ic_launcher" 
      app:layout_anchor="@id/overview_coordinator_layout" 
      app:layout_anchorGravity="bottom|right|end" /> 

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

    <android.support.design.widget.NavigationView 
     android:id="@+id/nvView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@android:color/white" 
     app:headerLayout="@layout/nav_header" 
     app:menu="@menu/navigationdrawer_main" /> 

</android.support.v4.widget.DrawerLayout> 
+0

第二個文本didnt也出現在incluse appbar中的浮動條也消失 – Moudiz

+0

嘗試包裝線性'nestedscrollview'內的佈局...我編輯了答案。 – rafsanahmad007

+0

Did not work the recylrview disapeared – Moudiz