最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android中drawable使用Shape資源

 更新時(shí)間:2017年01月02日 13:34:42   作者:yuminfeng728  
這篇文章主要為大家詳細(xì)介紹了Android中drawable使用Shape資源的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了drawable使用Shape資源的具體內(nèi)容,供大家參考,具體內(nèi)容如下

1.畫一條水平方向的虛線

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="line" >

  <stroke
    android:dashGap="3dp"
    android:dashWidth="6dp"
    android:width="1dp"
    android:color="#FF8C69" />

</shape>

Android:width=”1dp” 為線條的高度
android:dashGap=”3dp” 表示虛線間空隙的寬度,0表示一條實(shí)線;
android:dashWidth=”6dp” 表示每個(gè)虛線的寬度。

注意:在版本4.0以上,需要在控件中設(shè)置android:layerType=”software”,否則虛線無效,顯示為實(shí)線。

2.畫一條垂直方向的虛線

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromDegrees="90"
  android:toDegrees="90"
  android:drawable="@drawable/line" >

</rotate>

或者使用下面的方法

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromDegrees="90"
  android:toDegrees="90" >

  <shape android:shape="line" >
    <stroke
      android:dashGap="3px"
      android:dashWidth="6px"
      android:width="1dp"
      android:color="#FF8C69" />
  </shape>
</rotate>

3.畫一個(gè)實(shí)心圓

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="oval" >

  <solid android:color="#FF8C69" />

</shape>

4.畫一個(gè)圓環(huán)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:innerRadius="15dp"
  android:shape="ring"
  android:thickness="10dp"
  android:useLevel="false" >

  <solid android:color="#FF8C69" />

  <stroke
    android:width="1dp"
    android:color="#FF8C69" />

</shape>

android:innerRadius=”15dp” 設(shè)置尺寸,內(nèi)環(huán)的半徑
android:thickness=”10dp” 設(shè)置尺寸,環(huán)的厚度
android:useLevel=”false” boolean值,如果當(dāng)做是LevelListDrawable使用時(shí)值為true,否則為false.

android:innerRadiusRatio=”9” 浮點(diǎn)型,以環(huán)的寬度比率來表示內(nèi)環(huán)的半徑,表示內(nèi)環(huán)半徑等于環(huán)的寬度除以5,這個(gè)值是可以被覆蓋的,默認(rèn)為9.
android:thicknessRatio=”2” 浮點(diǎn)型,以環(huán)的寬度比率來表示環(huán)的厚度, 表示環(huán)的厚度就等于環(huán)的寬度除以2。這個(gè)值是可以被android:thickness覆蓋的,默認(rèn)值是3.

5.畫一個(gè)矩形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle" >

  <corners android:radius="30dp" />

  <solid android:color="#FF8C69" />

  <stroke
    android:width="1dp"
    android:color="#FF8C69" />

</shape>

總結(jié)

<?xml version="1.0" encoding="utf-8"?>
<!--
 shape drawable xml文件中定義的一個(gè)幾何圖形,定義在res/drawable/目錄下,文件名filename稱為訪問的資源ID 
 在代碼中通過R.drawable.filename進(jìn)行訪問,在xml文件中通過@[package:]drawable/filename進(jìn)行訪問。 
-->
<!--
 android:shape=["rectangle" | "oval" | "line" | "ring"] 
 shape的形狀,默認(rèn)為矩形,可以設(shè)置為矩形(rectangle)、橢圓形(oval)、線性形狀(line)、環(huán)形(ring)下面的屬性只有在android:shape="ring時(shí)可用: 
 android:innerRadius     尺寸,內(nèi)環(huán)的半徑。 
 android:innerRadiusRatio   浮點(diǎn)型,以環(huán)的寬度比率來表示內(nèi)環(huán)的半徑,例如,如果android:innerRadiusRatio,表示內(nèi)環(huán)半徑等于環(huán)的寬度除以5,這個(gè)值是可以被覆蓋的,默認(rèn)為9. 
 android:thickness           尺寸,環(huán)的厚度 
 android:thicknessRatio   浮點(diǎn)型,以環(huán)的寬度比率來表示環(huán)的厚度,例如,如果android:thicknessRatio="2", 那么環(huán)的厚度就等于環(huán)的寬度除以2。這個(gè)值是可以被android:thickness覆蓋的,默認(rèn)值是3. 
 android:useLevel       boolean值,如果當(dāng)做是LevelListDrawable使用時(shí)值為true,否則為false.

-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle" >

  <!--
      圓角 
  android:radius            整型半徑 
  android:topLeftRadius        整型左上角半徑 
  android:topRightRadius        整型右上角半徑 
  android:bottomLeftRadius       整型左下角半徑 
  android:bottomRightRadius      整型右下角半徑

  -->
  <corners
    android:bottomLeftRadius="20dp"
    android:bottomRightRadius="25dp"
    android:radius="8dp"
    android:topLeftRadius="5dp"
    android:topRightRadius="15dp" />

  <!--
     漸變色 
  android:startColor    顏色值 起始顏色 
  android:endColor     顏色值結(jié)束顏色 
  android:centerColor   整型漸變中間顏色,即開始顏色與結(jié)束顏色之間的顏色 
  android:angle      整型漸變角度(PS:當(dāng)angle=0時(shí),漸變色是從左向右。 然后逆時(shí)針方向轉(zhuǎn),當(dāng)angle=90時(shí)為從下往上。angle必須為45的整數(shù)倍) 
  android:type       ["linear" | "radial" | "sweep"] 漸變類型(取值:linear、radial、sweep) 
               linear 線性漸變,這是默認(rèn)設(shè)置 
               radial 放射性漸變,以開始色為中心。 
               sweep 掃描線式的漸變。 
  android:useLevel     ["true" | "false"]如果要使用LevelListDrawable對(duì)象,就要設(shè)置為true。設(shè)置為true無漸變。false有漸變色 
  android:gradientRadius  整型漸變色半徑.當(dāng) android:type="radial" 時(shí)才使用。單獨(dú)使用 android:type="radial"會(huì)報(bào)錯(cuò)。 
  android:centerX     整型漸變中心X點(diǎn)坐標(biāo)的相對(duì)位置 
  android:centerY     整型漸變中心Y點(diǎn)坐標(biāo)的相對(duì)位置

  -->
  <gradient
    android:angle="45"
    android:endColor="#80FF00FF"
    android:startColor="#FFFF0000" />

  <!--
      內(nèi)邊距,即內(nèi)容與邊的距離  
  android:left       整型左內(nèi)邊距
  android:top       整型上內(nèi)邊距
  android:right      整型右內(nèi)邊距
  android:bottom      整型下內(nèi)邊距

  -->
  <padding
    android:bottom="10dp"
    android:left="10dp"
    android:right="10dp"
    android:top="10dp" />

  <!--
     size 大小 
  android:width  整型寬度 
  android:height 整型高度

  -->
  <size android:width="600dp" />

  <!--
      內(nèi)部填充 
  android:color  顏色值填充顏色

  -->
  <solid android:color="#ffff9d77" />

  <!--
      描邊 
  android:width        整型描邊的寬度 
  android:color        顏色值描邊的顏色 
  android:dashWidth      整型表示描邊的樣式是虛線的寬度, 值為0時(shí),表示為實(shí)線。值大于0則為虛線。 
  android:dashGap       整型表示描邊為虛線時(shí),虛線之間的間隔 即“ - - - - ”

  -->
  <stroke
    android:width="2dp"
    android:color="#dcdcdc" />

</shape>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Flutter投票組件使用方法詳解

    Flutter投票組件使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Flutter投票組件的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • Flutter如何輕松實(shí)現(xiàn)動(dòng)態(tài)更新ListView淺析

    Flutter如何輕松實(shí)現(xiàn)動(dòng)態(tài)更新ListView淺析

    在Android中通常都會(huì)用到listview.那么flutter里面怎么用呢?下面這篇文章主要給大家介紹了關(guān)于Flutter如何輕松實(shí)現(xiàn)動(dòng)態(tài)更新ListView的相關(guān)資料,需要的朋友可以參考下
    2022-02-02
  • Android實(shí)現(xiàn)帶有進(jìn)度條的按鈕效果

    Android實(shí)現(xiàn)帶有進(jìn)度條的按鈕效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)帶有進(jìn)度條的按鈕效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • Android如何快速適配暗黑模式詳解

    Android如何快速適配暗黑模式詳解

    微信在前段時(shí)間的更新中也實(shí)現(xiàn)了暗黑模式,而蘋果系統(tǒng)也早就支持暗黑模式,Android也一樣可以實(shí)現(xiàn),下面這篇文章主要給大家介紹了關(guān)于Android如何快速適配暗黑模式的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • Android仿微信拍攝短視頻

    Android仿微信拍攝短視頻

    本文主要對(duì)Android仿微信拍攝短視頻的實(shí)現(xiàn)方法進(jìn)行介紹,其功能設(shè)置為類似于微信,點(diǎn)擊開始拍攝,設(shè)置最長(zhǎng)拍攝時(shí)間。具有很好的參考價(jià)值,需要的朋友一起來看下吧
    2016-12-12
  • Android判斷和監(jiān)聽底座狀態(tài)和類型的方法介紹

    Android判斷和監(jiān)聽底座狀態(tài)和類型的方法介紹

    這篇文章主要介紹了Android判斷和監(jiān)聽底座狀態(tài)和類型的方法介紹,例如判斷當(dāng)前底座狀態(tài)、判斷插入底座類型、監(jiān)控充電充電狀態(tài)等,需要的朋友可以參考下
    2014-06-06
  • Android中ScrollView嵌套GridView的解決辦法

    Android中ScrollView嵌套GridView的解決辦法

    前些日子在開發(fā)中用到了需要ScrollView嵌套GridView的情況,由于這兩款控件都自帶滾動(dòng)條,當(dāng)他們碰到一起的時(shí)候便會(huì)出問題,即GridView會(huì)顯示不全。下面小編給大家分享下解決方案,需要的朋友可以參考下
    2017-04-04
  • Android中搜索圖標(biāo)和文字居中的EditText實(shí)例

    Android中搜索圖標(biāo)和文字居中的EditText實(shí)例

    本篇文章主要介紹了Android中搜索圖標(biāo)和文字居中的EditText實(shí)例,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-06-06
  • 一文講解Kotlin中的contract到底有什么用

    一文講解Kotlin中的contract到底有什么用

    我們?cè)陂_發(fā)中肯定會(huì)經(jīng)常用Kotlin提供的一些通用拓展函數(shù),當(dāng)我們進(jìn)去看源碼的時(shí)候會(huì)發(fā)現(xiàn)許多函數(shù)里面有contract{}包裹的代碼塊,那么這些代碼塊到底有什么作用呢?下面這篇文章主要給大家介紹了關(guān)于Kotlin中contract到底有什么用的相關(guān)資料,需要的朋友可以參考下
    2022-01-01
  • android實(shí)現(xiàn)節(jié)點(diǎn)進(jìn)度條效果

    android實(shí)現(xiàn)節(jié)點(diǎn)進(jìn)度條效果

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)節(jié)點(diǎn)進(jìn)度條效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05

最新評(píng)論

鄂托克旗| 峨山| 昆山市| 清远市| 黔南| 永兴县| 舒兰市| 封丘县| 喀什市| 博兴县| 隆德县| 远安县| 米林县| 锡林浩特市| 高要市| 山阴县| 临江市| 兴山县| 竹溪县| 东方市| 务川| 健康| 鄂尔多斯市| 六盘水市| 宽城| 永嘉县| 时尚| 会泽县| 黔南| 西青区| 斗六市| 高密市| 泾源县| 大石桥市| 库尔勒市| 大同县| 新竹市| 贵港市| 梅州市| 连云港市| 大荔县|