美文网首页
给控件添加阴影

给控件添加阴影

作者: TMAC_EAH | 来源:发表于2021-02-05 15:39 被阅读0次
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#484"
        android:clipChildren="false"
        android:gravity="center"
        android:orientation="vertical"
        tools:ignore="MissingDefaultResource">
    
        <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="@dimen/dp60"
            android:background="@color/white"
            android:clipChildren="false"
            android:gravity="bottom"
            android:orientation="horizontal"
            tools:background="#484"
            tools:parentTag="androidx.appcompat.widget.LinearLayoutCompat">
    
            <View
                android:layout_width="@dimen/dp60"
                android:layout_height="@dimen/dp60"
                android:background="#00FF00" />
    
            <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="wrap_content"
                android:layout_height="@dimen/dp50"
                android:background="@color/white"
                android:clipChildren="false"
                android:gravity="center"
                android:orientation="horizontal"
                tools:background="#484"
                tools:parentTag="androidx.appcompat.widget.LinearLayoutCompat">
    
                <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="wrap_content"
                    android:layout_height="@dimen/dp50"
                    android:background="@color/white"
                    android:clipChildren="false"
                    android:gravity="center"
                    android:orientation="vertical"
                    tools:background="#484"
                    tools:parentTag="androidx.appcompat.widget.LinearLayoutCompat">
    
                    <View
                        android:layout_width="@dimen/dp60"
                        android:layout_height="@dimen/dp30"
                        android:background="#00FF00" />
    
                    <View
                        android:layout_width="@dimen/dp60"
                        android:layout_height="@dimen/dp20"
                        android:background="#FF0000" />
                </LinearLayout>
    
                <View
                    android:layout_width="@dimen/dp60"
                    android:layout_height="@dimen/dp60"
                    android:background="#0000FF" />
            </LinearLayout>
    
            <View
                android:layout_width="@dimen/dp60"
                android:layout_height="@dimen/dp55"
                android:background="@color/purple" />
        </LinearLayout>
    
        <View
            android:layout_width="@dimen/dp58"
            android:layout_height="@dimen/dp58"
            android:layout_gravity="center"
            android:layout_marginTop="@dimen/dp9"
            android:layout_marginBottom="@dimen/dp9"
            android:background="@drawable/white_circle_shape" />
    
        <View
            android:layout_width="@dimen/dp58"
            android:layout_height="@dimen/dp58"
            android:layout_gravity="center"
            android:layout_marginTop="@dimen/dp9"
            android:layout_marginBottom="@dimen/dp9"
            android:background="@drawable/white_circle_shape2" />
    
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp88"
            android:background="#484"
            android:clipChildren="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:visibility="visible"
            tools:ignore="MissingDefaultResource">
    
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="@dimen/dp50"
                android:layout_height="@dimen/dp50"
                android:background="#FF00"
                android:clipChildren="false"
                android:gravity="center"
                android:orientation="vertical"
                tools:ignore="MissingDefaultResource" />
    
            <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:id="@+id/rank_level_layout"
                android:layout_width="wrap_content"
                android:layout_height="@dimen/dp50"
                android:background="@color/white"
                android:clipChildren="false"
                android:gravity="center"
                android:orientation="vertical"
                tools:background="#484"
                tools:parentTag="androidx.appcompat.widget.LinearLayoutCompat">
    
                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/dp35"
                    android:layout_gravity="center|bottom"
                    android:clipChildren="false">
    
                    <FrameLayout
                        android:id="@+id/contentlayout"
                        android:layout_width="@dimen/dp44"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:visibility="visible"
                        app:layout_constraintTop_toTopOf="parent">
    
                        <ImageView
                            android:id="@+id/images"
                            android:layout_width="@dimen/dp24"
                            android:layout_height="@dimen/dp24"
                            android:layout_gravity="center"
                            android:scaleType="fitXY"
                            app:layout_constraintLeft_toLeftOf="parent"
                            app:layout_constraintRight_toRightOf="parent"
                            tools:src="@drawable/main_tab_circle" />
    
                        <TextView
                            android:id="@+id/unread"
                            android:layout_width="@dimen/dp7"
                            android:layout_height="@dimen/dp7"
                            android:layout_gravity="right"
                            android:layout_marginRight="@dimen/dp10"
                            android:background="@drawable/msg_tips_shape"
                            android:gravity="center"
                            android:singleLine="true"
                            android:textColor="@color/white"
                            android:visibility="gone"
                            tools:text=""
                            tools:visibility="visible" />
                    </FrameLayout>
    
                    <!--                <FrameLayout 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="@dimen/dp58"-->
                    <!--                    android:layout_height="@dimen/dp58"-->
                    <!--                    android:layout_gravity="center"-->
                    <!--            -->
                    <!--                    android:visibility="gone"-->
                    <!--                    app:layout_constraintTop_toTopOf="parent"-->
                    <!--                    tools:showIn="@layout/widget_image_key_vertical_func_layout"-->
                    <!--                    tools:visibility="visible">-->
                    <!--                    <View-->
                    <!--                        android:id="@+id/shadow_layer1"-->
                    <!--                        android:layout_width="@dimen/dp58"-->
                    <!--                        android:layout_height="@dimen/dp58"-->
                    <!--                        android:layout_marginBottom="@dimen/dp9"-->
                    <!--                        android:background="@drawable/main_tab_shadow_circle" />-->
                    <!--                </FrameLayout>-->
                    <!--                                <FrameLayout 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="@dimen/dp58"-->
                    <!--                                    android:layout_height="@dimen/dp58"-->
                    <!--                                    android:layout_gravity="center"-->
                    <!--                            -->
                    <!--                                    android:visibility="gone"-->
                    <!--                                    app:layout_constraintTop_toTopOf="parent"-->
                    <!--                                    tools:showIn="@layout/widget_image_key_vertical_func_layout"-->
                    <!--                                    tools:visibility="visible">-->
                    <!--                                </FrameLayout>-->
                    <View
                        android:id="@+id/shadow_layer1"
                        android:layout_width="@dimen/dp58"
                        android:layout_height="@dimen/dp58"
                        android:layout_gravity="center"
                        android:layout_marginBottom="@dimen/dp9"
                        android:background="@drawable/white_circle_shape2" />
                    <!--                    android:background="@drawable/main_tab_shadow_circle" />-->
    
                    <View
                        android:id="@+id/shadow_layer2"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="@color/white" />
    
                    <FrameLayout 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:id="@+id/shadow_layer3"
                        android:layout_width="@dimen/dp58"
                        android:layout_height="@dimen/dp58"
                        android:layout_gravity="center"
                        android:layout_marginBottom="@dimen/dp9"
                        android:visibility="visible"
                        app:layout_constraintTop_toTopOf="parent"
                        tools:showIn="@layout/widget_image_key_vertical_func_layout"
                        tools:visibility="visible">
    
                        <ImageView
                            android:id="@+id/shadow_images"
                            android:layout_width="@dimen/dp38"
                            android:layout_height="@dimen/dp38"
                            android:layout_gravity="center"
                            android:scaleType="fitXY"
                            android:src="@drawable/main_tab_circle"
                            app:layout_constraintLeft_toLeftOf="parent"
                            app:layout_constraintRight_toRightOf="parent" />
    
                        <TextView
                            android:id="@+id/shadow_unread"
                            android:layout_width="@dimen/dp7"
                            android:layout_height="@dimen/dp7"
                            android:layout_gravity="right"
                            android:layout_marginTop="@dimen/dp12"
                            android:layout_marginRight="@dimen/dp12"
                            android:background="@drawable/msg_tips_shape"
                            android:gravity="center"
                            android:singleLine="true"
                            android:textColor="@color/white"
                            android:visibility="gone"
                            tools:text=""
                            tools:visibility="visible" />
                    </FrameLayout>
    
                </FrameLayout>
    
                <TextView
                    android:id="@+id/keys"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/dp15"
                    android:includeFontPadding="false"
                    android:textColor="@color/color_333333"
                    android:textSize="9sp"
                    android:textStyle="bold"
                    app:layout_constraintTop_toBottomOf="@+id/contentlayout"
                    tools:text="首页" />
    
            </LinearLayout>
    
            <!--        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
            <!--            xmlns:tools="http://schemas.android.com/tools"-->
            <!--            android:layout_width="@dimen/dp67"-->
            <!--            android:layout_height="@dimen/dp67"-->
            <!--            android:background="#FF00"-->
            <!--            android:clipChildren="false"-->
            <!--            android:gravity="center"-->
            <!--            android:orientation="vertical"-->
            <!--            tools:ignore="MissingDefaultResource" />-->
    
        </LinearLayout>
    
        <ImageView
            android:layout_width="@dimen/dp48"
            android:layout_height="@dimen/dp48"
            android:background="@drawable/white_circle_shape"
            android:visibility="gone" />
    
        <FrameLayout
            android:layout_width="@dimen/dp54_5"
            android:layout_height="@dimen/dp54_5"
            android:clipChildren="false"
            android:visibility="gone">
    
            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="@dimen/dp6_5"
                android:background="@drawable/main_tab_shadow_circle" />
    
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/dp35"
                android:layout_gravity="bottom"
                android:background="#FF00" />
    
            <ImageView
                android:layout_width="@dimen/dp38"
                android:layout_height="@dimen/dp38"
                android:layout_gravity="center"
                android:scaleType="fitXY"
                android:src="@drawable/main_tab_circle" />
        </FrameLayout>
    </LinearLayout>
    
    

    white_circle_shape2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        tools:ignore="MissingDefaultResource">
        <item>
            <shape android:shape="oval">
                <padding
                    android:bottom="@dimen/dp1"
                    android:left="@dimen/dp1"
                    android:right="@dimen/dp1"
                    android:top="@dimen/dp1" />
                <solid android:color="#00CCCCCC" />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <padding
                    android:bottom="@dimen/dp1"
                    android:left="@dimen/dp1"
                    android:right="@dimen/dp1"
                    android:top="@dimen/dp1" />
                <solid android:color="#10CCCCCC" />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <padding
                    android:bottom="@dimen/dp1"
                    android:left="@dimen/dp1"
                    android:right="@dimen/dp1"
                    android:top="@dimen/dp1" />
                <solid android:color="#20CCCCCC" />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <padding
                    android:bottom="@dimen/dp1"
                    android:left="@dimen/dp1"
                    android:right="@dimen/dp1"
                    android:top="@dimen/dp1" />
                <solid android:color="#30CCCCCC" />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <padding
                    android:bottom="@dimen/dp1"
                    android:left="@dimen/dp1"
                    android:right="@dimen/dp1"
                    android:top="@dimen/dp1" />
                <solid android:color="#50CCCCCC" />
            </shape>
        </item>
    
        <!-- 中心背景 -->
        <item>
            <shape android:shape="oval">
                <!-- 实心 -->
                <solid android:color="#ffffff" />
                                        <padding
                                            android:bottom="@dimen/dp10"
                                            android:left="@dimen/dp10"
                                            android:right="@dimen/dp10"
                                            android:top="@dimen/dp10" />
            </shape>
        </item>
    </layer-list>
    
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <solid android:color="@color/red" />
    
    </shape>
    
    yinyin.jpg

    相关文章

      网友评论

          本文标题:给控件添加阴影

          本文链接:https://www.haomeiwen.com/subject/gdfgtltx.html