2016-10-26 35 views
0

我的主UI隐藏了我的Include UI。在第一张图片中,你可以看到我想要的东西。在我的用户界面中有标签,我想在标签之后,应该有一个小的用户界面将有它的细节。所以我创建了另一个小UI,并将其包含在我的主UI中。我的主标签UI隐藏了我的Include UI。请帮助我。DrawerLayout隐藏另一个布局

我理想中如下图enter image description here

问题,我在下面的图像布局

enter image description here

这里是相同的代码..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/backgroundimage" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical"> 

    <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/drawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

      <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
       app:layout_scrollFlags="scroll|enterAlways" 
       app:title="Test"> 

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


      <FrameLayout 
       android:id="@+id/containerView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 


      </FrameLayout> 


     </LinearLayout> 

     <android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/navigation_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:layout_marginTop="-24dp" 
      app:headerLayout="@layout/nav_header_navigation_drawer" 
      app:itemTextColor="@color/black" 
      app:menu="@menu/drawermenu" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 


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


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

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

    </LinearLayout> 

bottom_nowplaying_card代码如下

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/topContainer" 
    android:layout_width="wrap_content" 
    android:layout_height="60dp" 
    android:layout_gravity="top" 
    android:background="@color/graybackcolor"> 


    <ImageView 
     android:id="@+id/slide_bottom_song_image" 
     android:layout_width="55dp" 
     android:layout_height="55dp" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/musicicon" 
     android:paddingTop="10dp" 
     android:scaleType="centerCrop" /> 


    <LinearLayout 
     android:id="@+id/bottom_songsdetails" 
     android:layout_width="230dp" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="10dp" 
     android:layout_toRightOf="@+id/slide_bottom_song_image" 
     android:orientation="vertical" 
     android:paddingLeft="10dp" 
     android:paddingTop="5dp"> 

     <TextView 
      android:id="@+id/song_title_bar" 
      style="@style/AppTheme" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:ellipsize="end" 
      android:singleLine="true" 
      android:text="Please select song" 
      android:textColor="@color/textcolor" 
      android:textSize="16sp" /> 

     <TextView 
      android:id="@+id/song_artist_bar" 
      style="@style/AppTheme" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:ellipsize="end" 
      android:paddingTop="3dp" 
      android:singleLine="true" 
      android:text="sub Title" 
      android:textColor="@color/textcolor" 
      android:textSize="13sp" /> 

    </LinearLayout> 

    <LinearLayout 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="wrap_content" 
     android:layout_height="50dp" 
     android:orientation="horizontal" 
     android:layout_alignBottom="@+id/slide_bottom_song_image" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:layout_toRightOf="@+id/bottom_songsdetails" 
     android:layout_toEndOf="@+id/bottom_songsdetails"> 


     <net.steamcrafted.materialiconlib.MaterialIconView 
      android:id="@+id/play_pause_bottom" 
      android:layout_width="23dp" 
      android:layout_height="23dp" 
      android:layout_gravity="center" 
      android:layout_weight="0.6" 
      android:background="?attr/selectableItemBackgroundBorderless" 
      android:scaleType="center" 
      app:materialIcon="play" 
      app:materialIconColor="?attr/iconColor" 
      app:materialIconSize="35dp" /> 

     <net.steamcrafted.materialiconlib.MaterialIconView 
      android:id="@+id/playlist" 
      android:layout_width="23dp" 
      android:layout_height="23dp" 
      android:layout_gravity="center" 
      android:layout_weight="0.6" 
      android:background="?attr/selectableItemBackgroundBorderless" 
      android:scaleType="center" 
      app:materialIcon="playlist_plus" 
      app:materialIconColor="?attr/iconColor" 
      app:materialIconSize="35dp" /> 

    </LinearLayout> 

     </RelativeLayout> 

回答

1

没有变化在bottom_nowplaying_card代码需要

考虑更换以下XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/greencolor" 
       android:fitsSystemWindows="true" 
       android:orientation="vertical"> 

    <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/drawerLayout" 
              android:layout_width="match_parent" 
              android:layout_height="match_parent" 
     android:layout_above="@id/abc"> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

      <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
               android:id="@+id/toolbar" 
               android:layout_width="match_parent" 
               android:layout_height="wrap_content" 
               android:background="@android:color/transparent" 
               android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
               app:layout_scrollFlags="scroll|enterAlways" 
               app:title="Test"> 

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


      <FrameLayout 
       android:id="@+id/containerView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       > 


      </FrameLayout> 


     </LinearLayout> 

     <android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" 
                 xmlns:app="http://schemas.android.com/apk/res-auto" 
                 android:id="@+id/navigation_view" 
                 android:layout_width="wrap_content" 
                 android:layout_height="match_parent" 
                 android:layout_gravity="start" 
                 android:layout_marginTop="-24dp" 
                 app:headerLayout="@layout/nav_header_navigation_drawer" 
                 app:itemTextColor="@color/black" 
                 app:menu="@menu/drawermenu" 
                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 


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


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

    <include layout="@layout/bottom_nowplaying_card" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:id="@+id/abc"></include> 

</RelativeLayout> 

或尝试这个

<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:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/apptoolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@android:color/holo_orange_dark"> 
      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
       app:layout_scrollFlags="scroll|enterAlways" 
       app:title="Test"> 

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


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

     <FrameLayout 
      android:id="@+id/containerView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/holo_green_light" 
      android:layout_below="@id/apptoolbar" 
      android:layout_above="@id/include_layout"> 


     </FrameLayout> 

     <include layout="@layout/bottom_nowplaying_card" 
       android:id="@+id/include_layout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true"></include> 

    </RelativeLayout> 

<!--NavigationView as DrawerLayout’s drawer content view--> 

    <android.support.design.widget.NavigationView 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/drawer_header" 
     app:menu="@menu/navigationdrawer_menu"> 

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


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

得到以下错误。错误:(17,68)找不到与给定名称相匹配的资源(位于'layout_above',值为'@ id/abc')。另外为什么你评论NavigationView。我也想那样。对不起,但我是新来的android,为什么我要求sily qus –

+0

它的包含id ...请检查包含标记。 –

+0

只有它。我只是复制你的代码,并通过它。但得到同样的错误。不知道,但它得到相同的错误:( –

0

@Kushal Patil我发现了一些问题在你的设计,我会告诉ü一些变化... 请尝试一下

  1. 首先在你的Top XML

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

    这行代码添加以下的FrameLayout关闭ok

    frame layout's height should be wrap_content . 
    
  2. 现在在你的second XMLü从XML之上PDATE我下面的代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/topContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorGrey"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="60dp" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true"> 

    <---paste your content here..........ok ---> 

     </RelativeLayout> 
    </RelativeLayout> 
现在,如果你面对它的任何问题发表评论

。和 如果有帮助你不要忘了accept它。