bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

androidshape如何實現漸變色、分割線、邊框、半透明陰影效果

這篇文章主要介紹了android shape如何實現漸變色、分割線、邊框、半透明陰影效果,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

我們提供的服務有:成都網站設計、網站建設、微信公眾號開發、網站優化、網站認證、南安ssl等。為近1000家企事業單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的南安網站制作公司

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如何實現漸變色、分割線、邊框、半透明陰影效果

感謝你能夠認真閱讀完這篇文章,希望小編分享的“android shape如何實現漸變色、分割線、邊框、半透明陰影效果”這篇文章對大家有幫助,同時也希望大家多多支持創新互聯,關注創新互聯行業資訊頻道,更多相關知識等著你來學習!

文章名稱:androidshape如何實現漸變色、分割線、邊框、半透明陰影效果
URL標題:http://vcdvsql.cn/article14/gjojge.html

成都網站建設公司_創新互聯,為您提供軟件開發網站設計公司、靜態網站、建站公司網站改版、ChatGPT

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名