方法添加在倒塌的工具栏布局称号18dpx18dp大小的图片吧?但不是在工具栏 [英] ways to add 18dpx18dp size image right of title in collapsing toolbar layout? but not in toolbar

查看:192
本文介绍了方法添加在倒塌的工具栏布局称号18dpx18dp大小的图片吧?但不是在工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我想提出一个图标权利标题倒塌工具栏,如下所示


  • 倒塌,但我不希望它显示工具栏后。

  • 我要崩溃后隐藏。

  • but After collapsing i don't want it to show in tool bar.
  • i want to hide after collapsing.

我做了一些事情。使用

collapsingToolbarLayout.setTitle(item.getName());
        collapsingToolbarLayout.setForeground(getResources().getDrawable(R.drawable.ic_photo_library_white_24dp));

collapsingToolbarLayout.setTitle(item.getName()); collapsingToolbarLayout.setForeground(getResources().getDrawable(R.drawable.ic_photo_library_white_24dp));

这看起来是这样。


  • 我现在还在调整的形象。

  • i am still trying to adjust that image.

但我想隐藏折叠后的图像。 BEZ它看起来像这样。

but i want to hide that image after collapsing. bez it looks like this.

这是我的java code。

here is my java code.

private void setToolbar(Product item) {
((AppCompatActivity) getActivity()).setSupportActionBar((productToolBar));

ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
actionBar.setTitle("");
productToolBar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        getActivity().onBackPressed();
    }
});
collapsingToolbarLayout.setTitle(item.getName());
collapsingToolbarLayout.setForeground(getResources().getDrawable(R.drawable.ic_photo_library_white_24dp));
collapsingToolbarLayout.set
}

和我的XML文件。

<android.support.design.widget.CoordinatorLayout
android:id="@+id/product_detail_main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:apptools="http://schemas.android.com/tools"
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/product_detail_appBar_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/detail_product_collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:foregroundGravity="bottom|right"
    android:foregroundTintMode="add"
    android:clipToPadding="true"
    app:contentScrim="?attr/colorPrimary"
    app:expandedTitleMarginStart="@dimen/space_xxlarge"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/image"
        android:fitsSystemWindows="true"
        android:scaleType="centerCrop"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="0.7"/>

    <android.support.v7.widget.Toolbar
        android:id="@+id/product_toolBar_title"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:fitsSystemWindows="true"
        app:layout_collapseMode="pin"
        app:navigationIcon="@drawable/ic_arrow_back_white_24dp"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

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

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

<android.support.v4.widget.NestedScrollView
 ........
<android.support.design.widget.CoordinatorLayout

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆