CoordinatorLayout 协调者布局 滑动 改变标题 透明的或者布局,很简单的布局

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">

                

      <com.google.android.material.appbar.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:collapsedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
          app:contentScrim="?attr/colorPrimary"
          app:layout_scrollFlags="scroll|exitUntilCollapsed"
          app:statusBarScrim="?attr/colorPrimary"
          app:titleEnabled="false">

          <FrameLayout  //zhes
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

              <ImageView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:background="@mipmap/shop_bg" />

              <LinearLayout
                  android:layout_marginTop="100dp"
                  android:id="@+id/headLayout"
                  app:layout_scrollFlags="scroll"
                  android:layout_width="match_parent"
                  android:minHeight="85dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:orientation="vertical">

                  <FrameLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content">

                      <TextView
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:layout_marginTop="35dp"
                          android:background="@drawable/while_top_10r"
                          android:orientation="vertical" />

                      <LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:orientation="vertical">


                          <LinearLayout
                              android:id="@+id/shopvuiew"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="15dp"
                              android:layout_marginRight="15dp"
                              android:orientation="vertical">

                              <FrameLayout
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:orientation="horizontal">

                                  <com.facebook.drawee.view.SimpleDraweeView
                                      android:id="@+id/company_530_logo"
                                      android:layout_width="70dp"
                                      android:layout_height="70dp"
                                      android:src="@mipmap/liufei"
                                      app:placeholderImage="@mipmap/qiye_logo"
                                      android:scaleType="fitCenter"
                                      app:roundedCornerRadius="10dp" />


                              </FrameLayout>

                              <LinearLayout
                                  android:layout_marginTop="8dp"
                                  android:gravity="center_vertical"
                                  android:orientation="horizontal"
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content">

                                  <TextView
                                      android:layout_weight="1"
                                      android:id="@+id/company_530_name"
                                      android:layout_width="match_parent"
                                      android:layout_height="wrap_content"
                                      android:textColor="@color/c333333"
                                      tools:text="深圳稳健建设集团有限公司"
                                      android:textStyle="bold"
                                      android:ellipsize="end"
                                      android:singleLine="true"

                                      android:layout_marginLeft="5dp"
                                      android:justificationMode="none"
                                      android:textSize="20dp" />

                                  <TextView
                                      android:id="@+id/reling_com"
                                      android:background="@drawable/corner_15dp_radius_white_1f9547_line"
                                      android:paddingBottom="3dp"
                                      android:paddingTop="3dp"
                                      android:paddingLeft="5dp"
                                      android:paddingRight="5dp"
                                      android:textColor="#1f9547"
                                      android:text="认领企业"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content" />

                              </LinearLayout>


                              <LinearLayout
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:gravity="center_vertical"
                                  android:layout_margin="5dp"
                                  android:orientation="vertical">

                                  <TextView
                                      android:id="@+id/company_530_guimo"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:textColor="@color/c333333"
                                      android:text="建筑/建材/工程 . 1000人以上"
                                      android:justificationMode="none"
                                      android:textSize="@dimen/tzh_text_12dp_mess_fu" />

                                  <TextView
                                      android:layout_marginTop="5dp"
                                      android:id="@+id/company_530_used_name"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:textColor="@color/c333333"
                                      tools:text="曾用名"
                                      android:justificationMode="none"
                                      android:textSize="@dimen/tzh_text_12dp_mess_fu" />


                              </LinearLayout>


                              <LinearLayout
                                  android:orientation="horizontal"
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content">


                                  <LinearLayout
                                      android:layout_width="0dp"
                                      android:layout_height="wrap_content"
                                      android:layout_margin="5dp"
                                      android:layout_weight="1"
                                      android:gravity="center"
                                      android:orientation="vertical">

                                      <TextView
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content"
                                          android:text="企业法人"
                                          android:textColor="@color/color_ff6a6a6a"
                                          android:textSize="14sp" />

                                      <TextView
                                          android:id="@+id/company_530_legder"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content"
                                          android:layout_marginTop="5dp"
                                          android:text="王梦"
                                          android:textColor="@color/color_tuzhuhu_theme_color_080808"
                                          android:textSize="14sp"
                                          android:textStyle="bold" />


                                  </LinearLayout>

                                  <LinearLayout
                                      android:layout_margin="5dp"
                                      android:gravity="center"
                                      android:layout_weight="1"
                                      android:orientation="vertical"
                                      android:layout_width="0dp"
                                      android:layout_height="wrap_content">

                                      <TextView
                                          android:textSize="14sp"
                                          android:textColor="@color/color_ff6a6a6a"
                                          android:text="注册资金"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content" />

                                      <TextView
                                          android:id="@+id/company_530_register_money"
                                          android:layout_marginTop="5dp"
                                          android:textSize="14sp"
                                          android:textColor="@color/color_tuzhuhu_theme_color_080808"
                                          android:text="王梦"
                                          android:textStyle="bold"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content" />


                                  </LinearLayout>

                                  <LinearLayout
                                      android:layout_margin="5dp"
                                      android:gravity="center"
                                      android:layout_weight="1"
                                      android:orientation="vertical"
                                      android:layout_width="0dp"
                                      android:layout_height="wrap_content">

                                      <TextView
                                          android:textSize="14sp"
                                          android:textColor="@color/color_ff6a6a6a"
                                          android:text="成立日期"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content" />

                                      <TextView
                                          android:textStyle="bold"
                                          android:id="@+id/company_530_build_time"
                                          android:layout_marginTop="5dp"
                                          android:textSize="14sp"
                                          android:textColor="@color/color_tuzhuhu_theme_color_080808"
                                          android:text="2022-4-11"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content" />


                                  </LinearLayout>

                              </LinearLayout>

                              <View
                                  android:layout_marginTop="2dp"
                                  android:layout_marginBottom="2dp"
                                  android:background="@color/color_f6f6f6_spe"
                                  android:layout_width="match_parent"
                                  android:layout_height="1dp" />

                              <LinearLayout

                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_margin="5dp"
                                  android:orientation="horizontal">


                                  <com.tuzhuhu.app.view.expand_text.ExpandableTextView
                                      android:id="@+id/company_530_category_tv"
                                      android:layout_width="match_parent"
                                      android:layout_height="wrap_content"
                                      android:layout_centerVertical="true"
                                      android:layout_marginTop="5dp"
                                      android:lineSpacingExtra="2dp"
                                      tools:text="一般经营项目是:
                          混凝土预制结构工程、金属门窗、
                          保工程、土石方工程、市政工程、城市园林绿化工程、
                          混凝土预制结构工程、金属门窗、防水防"
                                      android:textColor="#868686"
                                      android:textSize="14sp"
                                      app:ep_contract_color="#07B4C4"
                                      app:ep_expand_color="#07B4C4"
                                      app:ep_max_line="2"
                                      app:ep_text_expend="更多"
                                      app:ep_mention_color="@color/white"
                                      app:ep_need_contract="true"
                                      app:ep_need_expand="true"
                                      app:ep_text_expend_iv="false"
                                      app:ep_need_link="false"
                                      app:ep_need_mention="false" />

                                  <!--      <TextView
                                            android:id="@+id/company_530_category_tv"
                                            android:layout_width="match_parent"
                                            android:layout_height="wrap_content"
                                            android:lineSpacingExtra="3dp"
                                            android:textColor="@color/c333333"
                                            tools:text="经营范围:1、建筑工程施工、装饰、装修 2、建筑工程施工、装饰、装修 2建筑工程施工、装饰、装修 2电气安装;管道
和设备安装"
                                            android:textStyle="bold"
                                            android:justificationMode="none"
                                            android:textSize="@dimen/tzh_text_12dp_mess_fu"/>-->


                              </LinearLayout>

                              <LinearLayout
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_marginTop="5dp"
                                  android:layout_marginBottom="10dp"
                                  android:orientation="horizontal">

                                  <com.tuzhuhu.app.view.FontIconView
                                      android:textColor="@color/color_tuzhuhu_theme_color"
                                      android:textSize="15sp"
                                      android:text="@string/position_local"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content" />

                                  <TextView
                                      android:id="@+id/company_530_dealadd"
                                      android:layout_width="match_parent"
                                      android:layout_height="wrap_content"
                                      android:layout_marginLeft="8dp"
                                      tools:text="广东省深圳市"
                                      android:lineSpacingExtra="3dp"
                                      android:textColor="@color/color_tuzhuhu_theme_color_080808"
                                      android:textSize="14sp" />

                              </LinearLayout>

                          </LinearLayout>

                      </LinearLayout>

                  </FrameLayout>


              </LinearLayout>



          </FrameLayout>
  <!--        android:layout_height="?attr/actionBarSize"-->
          <androidx.appcompat.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:contentInsetStart="0dp"
              app:layout_collapseMode="pin"
              app:title="@null">


              <LinearLayout
                  android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">
                  <TextView
                      android:layout_width="match_parent"
                      android:layout_height="35dp"/>
                  <FrameLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content">

                      <TextView
                          android:textStyle="bold"
                          android:id="@+id/tite_center_text"
                          android:layout_width="match_parent"
                          android:gravity="center"
                          android:layout_height="@dimen/title_height"
                          android:layout_centerInParent="true"
                          android:textColor="@color/white"
                          android:textSize="16sp"
                          android:text="企业主页" />

                      <ImageView
                          android:id="@+id/back_iv"
                          android:layout_width="@dimen/title_height"
                          android:layout_height="@dimen/title_height"
                          android:padding="15dp"
                          android:src="@mipmap/back_white" />
                      <LinearLayout
                          android:id="@+id/share_title"
                          android:paddingLeft="10dp"
                          android:paddingRight="20dp"
                          android:gravity="center"
                          android:layout_gravity="right"
                          android:layout_width="wrap_content"
                          android:layout_height="match_parent">
                          <ImageView
                              android:id="@+id/share_iamge"
                              android:tint="@color/white"
                              android:src="@mipmap/share_530"
                              android:layout_width="25dp"
                              android:layout_height="25dp"
                              tools:ignore="UseAppTint" />


                      </LinearLayout>

                  </FrameLayout>

              </LinearLayout>



          </androidx.appcompat.widget.Toolbar>


      </com.google.android.material.appbar.CollapsingToolbarLayout>

        

        </com.google.android.material.appbar.AppBarLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

这个里面包含的是标题

<com.google.android.material.appbar.CollapsingToolbarLayout
    android:id="@+id/collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:collapsedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
    app:contentScrim="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:statusBarScrim="?attr/colorPrimary"
    app:titleEnabled="false">
      
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

        // 这个地方是 滑动的主主题部分一般为一张图片活着ViewPager,视情况而定

</FrameLayout>

<androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:contentInsetStart="0dp"
    app:layout_collapseMode="pin"
    app:title="@null">

        //这个地方是入固定的顶部的标题,滑动的时候切换的话可以设置两套,渐变的话改变背景色

                

        <androidx.appcompat.widget.Toolbar
</com.google.android.material.appbar.CollapsingToolbarLayout>

滑动的时候处理,给AppBarLayout设置滑动监听,然后滑动的时候改变toolBar 的背景透明都, control.toolbar.getBackground().mutate().setAlpha(round);  记得要家 mutate(),否则会影响整体布局的 样式,滑动的时候也可以改变布局,都是一样的操作

control.AppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
    @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        int totalScrollRange = control.AppBarLayout.getTotalScrollRange();


        try {
            float percent = (Math.abs(verticalOffset * 1.0f) / 160);
            //toolbar渐变效果:
            int round = Math.round(255 * percent);

            PrintUtilsJava.pringtLog("onOffsetChanged----》001  = "+totalScrollRange +"  "+ verticalOffset +"   "+ round);

            if (round>7 && round<255){
                Drawable drawable = control.back_iv.getDrawable();
                DrawableCompat.setTint(drawable, Color.WHITE);

                Drawable drawable1 = control.share_iamge.getDrawable();
                DrawableCompat.setTint(drawable1, Color.WHITE);

                control.toolbar.getBackground().mutate().setAlpha(round);
                control.tite_center_text.setTextColor(Color.WHITE);
            }else if (round<7){
                control.toolbar.getBackground().mutate().setAlpha(0);
                control.tite_center_text.setTextColor(Color.WHITE);
                Drawable drawable = control.back_iv.getDrawable();
                DrawableCompat.setTint(drawable, Color.WHITE);

                Drawable drawable1 = control.share_iamge.getDrawable();
                DrawableCompat.setTint(drawable1, Color.WHITE);

            }else{
                control.toolbar.getBackground().mutate().setAlpha(1);
                control.toolbar.setBackgroundColor(Color.WHITE);
                control.tite_center_text.setTextColor(Color.BLACK);
                Drawable drawable = control.back_iv.getDrawable();
                DrawableCompat.setTint(drawable, Color.BLACK);

                Drawable drawable1 = control.share_iamge.getDrawable();
                DrawableCompat.setTint(drawable1, Color.BLACK);

            }

        }catch (Exception e){

        }



    }
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值