2016-04-17 7 views
1

Ich baue eine App mit dem neuen Koordinatorlayout. Ich folgte dem hier gezeigten Beispiel http://saulmm.github.io/mastering-coordinator über das benutzerdefinierte Verhalten. Ich habe das Beispiel in meinem Code erfolgreich implementiert, aber jetzt möchte ich eine weitere statische Ansicht unter der Symbolleiste hinzufügen, diese Ansicht sollte jederzeit entlang der Symbolleiste laufen. Ich kann es nicht funktionieren lassen, also war ich hoffnungsvoll, dass mich jemand hier aufklären könnte.Statische Ansicht zum Koordinatorlayout hinzufügen

hier ist mein xml ab jetzt

<android.support.design.widget.AppBarLayout 
     android:id="@+id/main.appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     > 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/main.collapsing" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" 
      > 

      <ImageView 
       android:id="@+id/main.imageview.placeholder" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:scaleType="centerCrop" 
       android:src="@drawable/login_background_2" 
       android:tint="#11000000" 
       app:layout_collapseMode="parallax" 
       app:layout_collapseParallaxMultiplier="0.9" 
       /> 

      <FrameLayout 
       android:background="@color/colorPrimary" 
       android:id="@+id/frameLayout" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:layout_gravity="bottom|center_horizontal" 
       android:orientation="vertical" 
       app:layout_collapseMode="parallax" 
       app:layout_collapseParallaxMultiplier="0.3" 

       > 

       <LinearLayout 
        android:id="@+id/main.linearlayout.title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:orientation="vertical" 
        > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center_horizontal" 
         android:gravity="bottom|center" 
         android:text="groupname" 
         android:textColor="@android:color/white" 
         android:textSize="30sp" 
         /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center_horizontal" 
         android:layout_marginTop="4dp" 
         android:text="group asda" 
         android:textColor="@android:color/white" 
         /> 

       </LinearLayout> 
      </FrameLayout> 
     </android.support.design.widget.CollapsingToolbarLayout> 


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


     <android.support.v7.widget.RecyclerView 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      > 
     </android.support.v7.widget.RecyclerView> 


    <android.support.v7.widget.Toolbar 
     android:id="@+id/main.toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/colorPrimary" 
     app:layout_anchor="@id/frameLayout" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark" 
     app:title="" 
     > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 
      <Space 
       android:layout_width="@dimen/image_final_width" 
       android:layout_height="@dimen/image_final_width" 
       /> 

      <TextView 
       android:id="@+id/main.textview.title" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:gravity="center_vertical" 
       android:layout_marginLeft="8dp" 
       android:text="afdfadfadf" 
       android:textColor="@android:color/white" 
       android:textSize="20sp" 
       /> 
      </LinearLayout> 

     </LinearLayout> 

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


    <de.hdodenhof.circleimageview.CircleImageView 
     android:layout_width="@dimen/image_width" 
     android:layout_height="@dimen/image_width" 
     android:src="@drawable/extension_mascot" 
     android:layout_gravity="center_horizontal" 
     app:layout_behavior="AvatarImageBehavior" 
     app:finalYPosition="2dp" 
     app:finalHeight="@dimen/image_final_width" 
     android:id="@+id/groupMascot" 
     app:startToolbarPosition="2dp" 
     app:startHeight="2dp" 
     app:startXPosition="2dp" 
     /> 

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

irgendwelche Ideen, wie dies geschehen soll? was ich unter der Symbolleiste hinzufügen möchte, ist ein lineares Layout mit 3 Textfeldern, die die gesamte Breite einnehmen und unter ihnen aufteilen. jede Hilfe würde sehr geschätzt werden!

Antwort

0

ich das gleiche Beispiel und löste das Problem machte die reoursce-Datei in den Ordner Werte hinzufügen, ist der Dateiname attrs.xml und sieht wie folgt aus:

<resources> 
    <declare-styleable name="AvatarImageBehavior"> 
     <attr name="finalYPosition" format="dimension"/> 
     <attr name="startXPosition" format="dimension"/> 
     <attr name="startToolbarPosition" format="dimension"/> 
     <attr name="startHeight" format="dimension"/> 
     <attr name="finalHeight" format="dimension"/> 
    </declare-styleable> 
</resources> 

Das hat mich das Problem

für mich lösen
Verwandte Themen