2016-12-08 42 views
0

在我的Android設備(Android 4.2)完美的作品,但在Adroid 6我有一個CollapsingToolbarLayout問題。它仍然是藍色的標籤,並用圖標調整標籤:摺疊標題離開blueLabel時崩潰

在Anroid的6 enter image description here

在Android 4.2(正確)

enter image description here

import net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout; 

public class Model extends Activity{ 

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.layout); 
     localLang=Locale.getDefault().getLanguage(); 
     typeface =Typeface.createFromAsset(getAssets(),"fonts/fontawesome-webfont.ttf"); 
     getData(); 

     setCollapseTitle(obj.getTitle()); 
     backButton=(Button) findViewById(R.id.backButton); 
     backButton.setTypeface(typeface); 
     backButton.setText(R.string.navLeft); 
     backButton.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       finish(); 
      } 
     }); 

     notificationBadge.setText(Integer.toString(NotificationList.size())); 
     settingsButton=(Button)findViewById(R.id.settingsDrawer); 
     settingsButton.setTypeface(typeface); 
     settingsButton.setText(getResources().getString(R.string.settingDrawer)); 
     final SettingsDrawer settingsDrawer=new SettingsDrawer(getWindow().getDecorView().findViewById(android.R.id.content), 
       Model.this); 
     settingsButton.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
         settingsDrawer.openAndCollapseDrawerList(); 
      } 
     }); 

    }} 
     private void setCollapseTitle(String s){ 
     CollapsingToolbarLayout mCollapsingToolbarLayout=(CollapsingToolbarLayout) findViewById(R.id.collapsing); 
     mCollapsingToolbarLayout.setTitle(s); 
     mCollapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedAppBarTopic); 
     mCollapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedAppBarTopic); 
    } 


    XML 



    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="9"> 
<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/background_light" 
    android:fitsSystemWindows="true"> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/AppBarLayoutHeight" 
     android:background="@color/blue" 
     android:fitsSystemWindows="true" 
     > 

     <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout 
      android:id="@+id/collapsing" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:contentScrim="@color/darkGray" 
      app:expandedTitleTextAppearance="@style/CollapsedAppBarTopic" 
      app:expandedTitleMarginStart="10dp" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginBottom="5dp" 
      > 

      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="3dp" 
       app:layout_collapseMode="parallax" 
       android:layout_alignParentTop="true" 
       > 
       <ImageView 
        android:id="@+id/imageTitleBackground" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@color/blue" /> 


       <ImageView 
        android:contentDescription="@string/logo" 
        android:id="@+id/logo" 
        android:layout_width="200dp" 
        android:layout_height="200dp" 
        android:layout_centerInParent="true" 
        android:layout_alignParentTop="true" /> 
      </RelativeLayout> 



      <android.support.v7.widget.Toolbar 
       android:id="@+id/main.toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:layout_collapseMode="pin" 
       /> 
     </net.opacapp.multilinecollapsingtoolbar.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" 
     > 

    // <CONTENT TEXTVIEWS ETC. 
    </android.support.v4.widget.NestedScrollView> 
</android.support.design.widget.CoordinatorLayout> 
</LinearLayout> 
+0

請問您可以添加代碼 –

+0

嘗試添加一行 android:fitsSystemWindows =「true」到您的CollapsingToolBar –

回答

0

發佈您的代碼。現在看起來就像藍色標籤是動作欄。我們不能推斷它,除非我們看到代碼。

+0

代碼添加,我想應該只在AppCompatActivity中顯示操作欄 – Expiredmind