メインコンテンツへスキップ

AndroidLiquidGlassView


AndroidLiquidGlassView

XMLレイアウト

<RelativeLayout
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- コンテンツコンテナ -->
    <FrameLayout
        android:id="@+id/content_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/images"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/image" />

        </RelativeLayout>
    </FrameLayout>

    <!-- 液体ガラスビュー -->
    <com.qmdeve.liquidglass.widget.LiquidGlassView
        android:id="@+id/liquidGlassView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerInParent="true" />
</RelativeLayout>

サンプリングソースのバインド

Java
ViewGroup content = findViewById(R.id.content_container);
LiquidGlassView liquidGlassView = findViewById(R.id.liquidGlassView);

// サンプリングソースをバインド
liquidGlassView.bind(content);

主なAPI

方法説明デフォルト値
bind(ViewGroup source)サンプリングソースをバインド-
setCornerRadius(float px)角の半径を設定 (px) (0dp-99dp)40dp
setRefractionHeight(float px)屈折の高さを設定 (px) (12dp-50dp)20dp
setRefractionOffset(float px)屈折のオフセットを設定 (px) (20dp-120dp)70dp
setTintColorRed(float red)色調(R)を設定 (0f-1f)1.0f
setTintColorGreen(float green)色調(G)を設定 (0f-1f)1.0f
setTintColorBlue(float blue)色調(B)を設定 (0f-1f)1.0f
setTintAlpha(float alpha)色調の可視度を設定 (0f-1f)0.0f
setDispersion(float dispersion)色散効果を設定 (0f-1f)-
setBlurRadius(float radius)ぼかし半径を設定0f
setDraggableEnabled(boolean enable)ドラッグを有効/無効にするfalse
setElasticEnabled(boolean enable)弾性効果を有効/無効にするfalse
setTouchEffectEnabled(boolean enable)ハイライト効果を有効/無効にするfalse