6

Update: dies geschieht auf Android 5.0, aber es funktioniert gut auf 5.1. Ich legte diese Frage (https://code.google.com/p/android/issues/detail?id=175240) und es sieht aus wie es wird in der nächsten Version derCollapsingToolbarLayout funktioniert nicht richtig

Bibliothek aufgenommen werden

so habe ich mit dem neuen Design Support Library gespielt, und ich habe in einige Probleme laufen. Ich denke, ich habe die meisten von ihnen gelöst, aber ich kann das nicht zur Arbeit bringen. Eigentlich funktioniert nicht einmal die provided example auf meinem Handy richtig.

Das Problem ist, dass wenn die Symbolleiste erweitert wird, die Symbole viel zu hoch sind. Und wenn sie zusammenbrechen, sind sie einfach weg. Siehe Screenshots.

Ich versuche dies auf einem Moto X läuft 5.0. Ich weiß, dass dies in mehr Geräten passiert, aber es funktioniert tatsächlich auf einigen von ihnen. Passierst du das? Jede bekannte Problemumgehung?

arrow and contextual menu are almost out of the screen and they are gone here

+0

arbeiten werde Sie könnten einige Code schreiben müssen für irgendeine Hilfe. – Psypher

+0

@Ranjith Ich habe einen Link zum "offiziellen" Repo (https://github.com/chrisbanes/cheesesquare/) da das Beispiel nicht funktioniert entweder – aows

+0

Ich habe diesen Code aus Repo ... Dieser Code funktionierte perfekt für mich .... – Psypher

Antwort

1

fand ich dieses Phänomen in der Android 5.0 und oben

seine

Das ist meine Art und Weise zu lösen: Löschen "android: fitsSystemWindows =" true "" in android.support.design .widget.CoordinatorLayout.

So:

<?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" 
android:id="@+id/main_content" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/detail_backdrop_height" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
+1

Entfernen von FitSystemWindows = "True" wird die Platzierung der Toolbar korrekt, aber Sie verlieren die Möglichkeit, Ihre Ansicht in die Statusleiste zu erweitern. – Patrick

+0

Ich habe jetzt gefunden. Ich denke, das ist ein Fehler auf Android 5.0. Ich have nicht goaog idea.sorry –

+0

Ich weiß nicht, ob es ein Fehler auf Android 5.0 oder in dieser Bibliothek ist, aber es funktioniert nicht auf 5.0 und es funktioniert auf 5.1. – aows

0

Das in com.android.support:design:22.2.0 ein bekannter Fehler ist. Es ist bereits behoben, es ist als zukünftige Veröffentlichung unter Google-Problemen markiert. Also lasst uns hoffen, dass es bald behoben sein wird. Verbindungen mit Fragen: https://code.google.com/p/android/issues/detail?id=175240 und https://code.google.com/p/android/issues/detail?id=175069

+0

Ja, eigentlich war ich es, der dieses Problem einreichte, da ich hier keine gute Antwort hatte. – aows

1

ich fix it programmatisch Symbolleiste Rand Satz verwendet und die Symbolleiste android gesetzt: fitsSystemWindows = "true".

Auf activity_detail.xml Layout:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

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

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleMarginEnd="64dp"> 

      <ImageView 
       android:id="@+id/backdrop" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="centerCrop" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax" /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="pin" /> 

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

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

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:paddingTop="24dp"> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="@dimen/card_margin"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Info" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/cheese_ipsum" /> 

       </LinearLayout> 

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

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Friends" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/cheese_ipsum" /> 

       </LinearLayout> 

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

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Related" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/cheese_ipsum" /> 

       </LinearLayout> 

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

     </LinearLayout> 

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

    <android.support.design.widget.FloatingActionButton 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     app:layout_anchor="@id/appbar" 
     app:layout_anchorGravity="bottom|right|end" 
     android:src="@drawable/ic_discuss" 
     android:layout_margin="@dimen/fab_margin" 
     android:clickable="true"/> 

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

auf CheeseDetailActivity:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_detail); 

    Intent intent = getIntent(); 
    final String cheeseName = intent.getStringExtra(EXTRA_NAME); 

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    TypedValue tv = new TypedValue(); 
    if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { 
     int actionBarHeight = (int) (TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()) 
       - (getResources().getDimension(R.dimen.abc_action_bar_default_padding_material))*2); 
     FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) toolbar.getLayoutParams(); 
     layoutParams.topMargin = - (actionBarHeight/2); 
     toolbar.setLayoutParams(layoutParams); 
    } 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

    CollapsingToolbarLayout collapsingToolbar = 
      (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 
    collapsingToolbar.setTitle(cheeseName); 

    loadBackdrop(); 
} 

Ergebnisse: http://s22.postimg.org/nnwi0mh41/initial.png http://s22.postimg.org/8cmp00js1/collapsed.png

4

auf

com.android.support:design:22.2.1 
01 Fest
-2

entfernen android: fitsSystemWindows = "true"

+0

Ich würde ein bisschen Erklärung eher als eine einzeilige Antwort empfehlen. –

0

diese Zeile collapsingToolBar Layout hinzufügen: App: layout_scrollFlags = "scroll | exitUntilCollapsed"

es