Elevation高度、shadows阴影、clipping裁剪、tint着色
最后更新于
最后更新于
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#000"
android:elevation="10dp">
</FrameLayout>
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_x="50dp"
android:layout_y="50dp"
android:background="#CCC"
android:elevation="5dp">
</FrameLayout>
</AbsoluteLayout><!-- res/drawable/myrect.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#42000000" />
<corners android:radius="5dp" />
</shape><FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/myrect"
android:elevation="5dp">
</FrameLayout>ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
outline.setOval(0, 0, size, size);
}
};
fab.setOutlineProvider(viewOutlineProvider); <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:elevation="20dp"
android:outlineProvider="bounds">
</FrameLayout>
</LinearLayout> <ImageView
android:layout_width="180dp"
android:layout_height="180dp"
android:padding="10dp"
android:elevation="20dp"
android:outlineProvider="paddedBounds"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="180dp"
android:layout_height="180dp"
android:padding="10dp"
android:elevation="20dp"
android:outlineProvider="bounds"
android:src="@mipmap/ic_launcher"/>int margin = Math.min(clippedView.getWidth(), clippedView.getHeight()) / 10;
Outline mClip = new Outline();
mClip.setRoundRect(margin, margin, clippedView.getWidth() - margin,
clippedView.getHeight() - margin, margin / 2);
/* Sets the Outline of the View. */
clippedView.setOutline(mClip);
/* Enables clipping on the View. */
clippedView.setClipToOutline(true); <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"
android:tintMode="screen"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"
android:tintMode="add"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"
android:tintMode="src_atop"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"
android:tintMode="src_in"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@mipmap/ic_launcher"
android:tint="@color/colorPrimary"
android:tintMode="src_over"/>
</LinearLayout>