折叠标题在折叠时留下blueLabel

时间:2016-12-08 14:13:36

标签: android layout android-collapsingtoolbarlayout

在我的Android设备(Android 4.2)上运行完美,但在Adroid 6上我遇到了CollapsingToolbarLayout的问题。它仍然是蓝色标签,并使用图标调整标签大小:

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

1 个答案:

答案 0 :(得分:0)

发布您的代码。它现在的样子就像蓝色标签是动作栏。除非我们看到代码,否则我们无法推断它。