代码之家  ›  专栏  ›  技术社区  ›  Marco Tondini

在使用毕加索显示的图像视图上方放置一张纸条

  •  0
  • Marco Tondini  · 技术社区  · 8 年前

    我用毕加索在工具栏的ImageView中展示了一幅图像,我必须让工具栏标题可读,即使它是B&所以我想添加一张从图片底部开始添加阴影的纸片,就像这样。

    Left without scrim, right with scrim

    ImageView header;
        header = findViewById(R.id.tour_image);
    
        if(String.valueOf(getIntent().getStringExtra("image")).equals(getApplicationContext().getResources().getString(R.string.no_image))) {
            Picasso.get()
                    .load(String.valueOf(getIntent().getStringExtra("image")))
                    .fit()
                    .centerInside()
                    .into(header);
        }else{
            Picasso.get()
                    .load(String.valueOf(getIntent().getStringExtra("image")))
                    .fit()
                    .into(header);
        }
    
        header.setBackground(getResources().getDrawable(R.drawable.scrim));
    

    <ImageView
                android:id="@+id/tour_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/scrim"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"/>
    

    1 回复  |  直到 8 年前
        1
  •  1
  •   Deval    8 年前

    添加带有scrim-in的视图

         <android.support.design.widget.CollapsingToolbarLayout>
    
             <ImageView />
    
             <View 
                 background="@drawable/scrim"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent" />
    
             <android.support.v7.widget.Toolbar />
    
         </android.support.design.widget.CollapsingToolbarLayout>