2016-04-29 67 views
0

我想獲得一個視圖(LinearLayout)感覺像是ActionBar的擴展。我使用AppCompat對象btw。安卓視圖與相同的ActionBar海拔

這是我的xml:

<android.support.design.widget.CoordinatorLayoutt 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=".RegisterActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay.Colored"> 

     <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_register" /> 

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

而現在的content_register佈局:

<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:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimary" 
     android:elevation="4dp" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="8dp" 
      android:text="text1" 
      android:textColor="@color/white" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="8dp" 
      android:text="text2" 
      android:textColor="@color/white" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:background="#40FFFFFF" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="8dp" 
      android:text="text3" 
      android:textColor="@color/white" /> 

    </LinearLayout> 


    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:padding="8dp" 
     android:text="insert awesome stuff here" /> 

</LinearLayout> 

什麼是我想要做如下圖所示: Pretended results

這是我得到的。 Results so far

關於如何修復此佈局的任何想法?我是否使用錯誤的組件?

此外,我應該使用CardView的佈局與text1 2 3?

回答

1

在樣式添加這個(換棒棒糖預設備)

<item name="android:windowContentOverlay">@null</item> 

在AppBarLayout

app:elevation="0dp" 
+0

不工作添加此行。仍然有同樣的想要的效果。 – HelderMPinhal

+0

您測試了哪個版本? –

+0

我不得不把它放在AppBarLayout中。它在那裏工作。 – HelderMPinhal