2016-04-29 11 views
0

Ich versuche, eine Ansicht (LinearLayout) wie eine Erweiterung der ActionBar zu fühlen. Ich verwende AppCompat Objekte btw.Android View mit der gleichen ActionBar Elevation

Das ist mein 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> 

Und jetzt das content_register Layout:

<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> 

Was ich mit vertreten versuchen im folgende Bild zu tun: Pretended results

Und das ist was ich bekomme. Results so far

Irgendwelche Ideen, wie ich dieses Layout reparieren kann? Benutze ich die falschen Komponenten?

Auch sollte ich ein CardView für das Layout mit Text1 2 3 verwenden?

Antwort

1

Fügen Sie diese in den Stilen (für Pre-Lolipop Geräte)

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

diese Zeile in Ihrer AppBarLayout hinzufügen

app:elevation="0dp" 
+0

Problem. Hat immer noch den gleichen gewünschten Effekt. – HelderMPinhal

+0

In welcher Version sind Sie getestet? –

+0

Ich musste das im AppBarLayout platzieren. Es hat dort funktioniert. – HelderMPinhal