線上直播系統原始碼,Android開發之自帶陰影效果的shape

zhibo系統開發發表於2022-05-11

線上直播系統原始碼,Android開發之自帶陰影效果的shape

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="
    <item>
        <shape>
            <corners
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <solid android:color="#10eeeeee" />
 
        </shape>
    </item>
    <item>
        <shape>
            <corners
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <solid android:color="#10eeeeee" />
 
        </shape>
    </item>
    <item>
        <shape>
            <corners
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <solid android:color="#40eeeeee" />
 
        </shape>
    </item>
    <item>
        <shape>
            <corners
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <solid android:color="#50eeeeee" />
 
        </shape>
    </item>
    <item>
        <shape>
            <corners
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <solid android:color="#60eeeeee" />
 
        </shape>
    </item>
    <!-- Background -->
    <item>
        <shape>
            <solid android:color="#ffffff" />
            <corners android:radius="10dp" />
        </shape>
    </item>
</layer-list>


將View轉成圖片的方法

 /**
     * 將View轉成Bitmap
     *
     * @param view View
     * @return Bitmap
     */
    private Bitmap createViewBitmap(View view) {
 
        Bitmap bitmap;
        int height = 0;
        int length = rlRoot.getChildCount();
        for (int i = 0; i < length; i++) {
            height += rlRoot.getChildAt(i).getHeight();
        }
        bitmap = Bitmap.createBitmap(view.getWidth(), height, Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    }


以上就是 線上直播系統原始碼,Android開發之自帶陰影效果的shape,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2893476/,如需轉載,請註明出處,否則將追究法律責任。

相關文章