我试图向CollapsingToolbarLayout中存在的ImageView添加褪色边框,但是失败了。
我尝试过的代码只是一个简单的折叠工具栏
using Microsoft.MixedReality.Toolkit.Input;
public class MoveTo : BaseInputHandler, IMixedRealityInputHandler
{
public GameObject Sphere;
public GameObject Cursor;
public void OnInputUp(InputEventData eventData)
{
GetComponent<MeshRenderer>().material.color = Color.red;
}
public void OnInputDown(InputEventData eventData)
{
Vector3 gazePos = Cursor.transform.position;
Sphere.transform.position = gazePos;
GetComponent<MeshRenderer>().material.color = Color.green;
}
}
可绘制代码
=IFERROR(IF(SEARCH("*local*",B2,1),"Local"),IF(SEARCH("*national*",B2,1),"National"))
答案 0 :(得分:0)
要实现ImageView
的淡入淡出,可以在布局中添加一个名为FadingEdgeLayout的库。
FadingEdgeLayout
添加到build.gradle
中的项目中implementation 'com.github.bosphere.android-fadingedgelayout:fadingedgelayout:1.0.0'
<com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/collapsing_detail_buddhism" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" app:title="" app:expandedTitleMarginStart="10dp" app:expandedTitleMarginBottom="20dp" app:expandedTitleMarginTop="20dp" app:expandedTitleTextAppearance="@style/Base.TextAppearance.AppCompat.Display1" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/colorPrimaryDark" > <com.bosphere.fadingedgelayout.FadingEdgeLayout android:layout_width="match_parent" android:layout_height="match_parent" app:fel_edge="bottom" > <ImageView android:id="@+id/main_image" android:layout_width="match_parent" android:layout_height="220dp" android:src="@drawable/stories_background" android:scaleType="centerCrop" /> </com.bosphere.fadingedgelayout.FadingEdgeLayout> <android.support.v7.widget.Toolbar android:id="@+id/toolbar_detail_buddhism" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:layout_collapseMode="pin"/> </com.google.android.material.appbar.CollapsingToolbarLayout>
将布局更改为上方会为ImageView
添加褪色边缘。
但是请记住,FadingEdgeLayout
将背景色作为褪色边缘的颜色,因此我添加了android:background="@color/colorPrimaryDark"
,因此您会注意到它需要的颜色边缘。
您还可以添加更多边缘(底部,左侧,顶部,右侧),控制渐变的大小等。转到答案顶部提到的链接。