본문 바로가기

Android

[Android] OutlineProvider에 대해

OutlineProvider 한국말로는 외곽선 제공자 정도인 것 같다.

OutlineProvider가 영향을 끼치는 곳은 setClipToOutline과 elevation을 주었을 때 생기는 그림자정도 인 것 같다.

기본 View의 OutlineProvider는 BACKGROUND이다.

위에서부터 BACKGROUND, BOUNDS, PADDED_BOUNDS

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <View
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_margin="16dp"
        android:background="@drawable/bg_test"
        android:elevation="8dp"
        android:outlineAmbientShadowColor="@color/colorAccent"
        android:outlineProvider="background"
        android:outlineSpotShadowColor="@color/colorPrimary"
        android:text="Hello World!"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_margin="16dp"
        android:background="@drawable/bg_test"
        android:elevation="8dp"
        android:outlineAmbientShadowColor="@color/colorAccent"
        android:outlineProvider="bounds"
        android:outlineSpotShadowColor="@color/colorPrimary"
        android:text="Hello World!"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_margin="16dp"
        android:background="@drawable/bg_test"
        android:elevation="8dp"
        android:outlineAmbientShadowColor="@color/colorAccent"
        android:outlineProvider="paddedBounds"
        android:outlineSpotShadowColor="@color/colorPrimary"
        android:padding="16dp"
        android:text="Hello World!" />

</LinearLayout>