国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

android shape的使用及漸變色、分割線、邊框、半透明陰影

2019-10-21 21:41:23
字體:
來源:轉載
供稿:網友

shape使用、漸變色分割線邊框、半透明、半透明陰影效果。

首先簡單了解一下shape中常見的屬性。(詳細介紹參看 api文檔

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle" | "oval" | "line" | "ring"] > --- 默認為rectangle <corners -- shape=“rectangle”時使用,   android:radius="integer" -- 半徑,會被下邊的屬性覆蓋,默認為1dp,  android:topLeftRadius="integer"   android:topRightRadius="integer"  android:bottomLeftRadius="integer"  android:bottomRightRadius="integer" /> <gradient -- 漸變  android:angle="integer"  android:centerX="integer"  android:centerY="integer"  android:centerColor="integer"  android:endColor="color"  android:gradientRadius="integer"  android:startColor="color"  android:type=["linear" | "radial" | "sweep"]  android:useLevel=["true" | "false"] /> <padding  android:left="integer"  android:top="integer"  android:right="integer"  android:bottom="integer" /> <size -- 指定大小,一般用在imageview配合scaleType屬性使用。大小一般會適配滴  android:width="integer"  android:height="integer" /> <solid -- 填充顏色,可是是十六進制顏色。(比如想設置半透明效果,直接使用十六就只就OK)  android:color="color" /> <stroke -- 指定邊框,border,dashWidth和dashGap有一個為0dp則為實線  android:width="integer"  android:color="color"  android:dashWidth="integer" -- 虛線寬度  android:dashGap="integer" /> -- 虛線間隔寬度</shape>

注意:

<corners>

1、android:radius,半徑,會被下邊的單個角度半徑屬性覆蓋,默認為1dp,

2、在使用時,如果單獨設置四個角度,又大小不一致時,eclipse的graphics preview會報錯。但是直接真機運行即可。(比如實線上邊直角,下邊屈角的效果)

<size>

Note: The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an ImageView, you can restrict scaling by setting the android:scaleType to "center"

舉個栗子:

1、漸變色 res/drawable/gradient_box.xml:

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient  android:startColor="#FFFF0000"  android:endColor="#80FF00FF"  android:angle="45"/> <padding android:left="7dp"  android:top="7dp"  android:right="7dp"  android:bottom="7dp" /> <corners android:radius="8dp" /></shape>

如圖:

android,shape,漸變色,分割線,邊框,半透明陰影

2、白色邊框、半透明效果

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="16dp" /> <!-- 這是半透明,還可以設置全透明,那就是白色邊框的效果了 --> <solid android:color="#80065e8d" /> <stroke  android:dashGap="0dp"  android:width="4dp"  android:color="@android:color/white" /></shape>

如圖:

android,shape,漸變色,分割線,邊框,半透明陰影   android,shape,漸變色,分割線,邊框,半透明陰影

3、分割線效果:

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke  android:width="4dp"  android:color="@android:color/black" /></shape>

如圖:

android,shape,漸變色,分割線,邊框,半透明陰影

4、單邊屈角效果

<?xml version="1.0" encoding="utf-8"?><shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">  <corners   android:topLeftRadius="5dp"  android:topRightRadius="5dp"  android:bottomLeftRadius="30dp"  android:bottomRightRadius="30dp"/>  <!-- 這是半透明,還可以設置全透明,那就是白色邊框的效果了 --> <solid android:color="#ff065e8d" />  <stroke  android:dashGap="0dp"  android:width="4dp"  android:color="@android:color/white" /> </shape>

如圖:

android,shape,漸變色,分割線,邊框,半透明陰影

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁南县| 化隆| 湘乡市| 乐清市| 福州市| 道孚县| 富宁县| 余江县| 天气| 广州市| 镇康县| 台南县| 龙江县| 舞钢市| 屏南县| 上林县| 汤阴县| 进贤县| 新巴尔虎右旗| 马关县| 南昌县| 珲春市| 积石山| 闵行区| 郴州市| 沿河| 龙海市| 都匀市| 孟连| 镇原县| 高清| 客服| 龙门县| 宁远县| 奎屯市| 古蔺县| 乌拉特前旗| 临安市| 阳山县| 门源| 安平县|