下面定義三個(gè)shape資源my_shape_1.xml

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

初學(xué)Android,使用Drawable資源之使用ShapeDrawa

系統(tǒng) 1927 0

ShapeDrawable比較簡單,用來定義一個(gè)基本幾何圖形,XML的根元素是<shape.../>

下面定義三個(gè)shape資源

my_shape_1.xml

?

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" >
    <!-- 設(shè)置填充顏色 -->
    <solid android:color="#fff"/>
    <!-- 設(shè)置四周的內(nèi)邊距 -->
    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp"/>
    <!-- 設(shè)置邊框 -->
    <stroke android:width="3dip" android:color="#ff0"/>
</shape>
  

my_shape_2.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"/>
    <!-- 設(shè)置內(nèi)填充 -->
    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp"/>
    <!-- 設(shè)置圓角矩形 -->
    <corners android:radius="8dp"/>
</shape>
  

my_shape_3.xml

?

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval" >
    <!-- 定義填充漸變顏色 -->
    <gradient android:startColor="#ff0"
        android:endColor="#00f"
        android:angle="45"
        android:type="sweep"/>
    <!-- 設(shè)置內(nèi)填充 -->
    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp"/>
    <!-- 設(shè)置圓角矩形 -->
    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp"/>
    <!-- 設(shè)置圓角矩形 -->
    <corners android:radius="8dp"/>
</shape>
  

主界面的三個(gè)EditBox的背景分別使用上前面定義的三個(gè)shape

?

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" 
        android:background="@drawable/my_shape_1">

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" 
        android:background="@drawable/my_shape_2"/>

    <EditText
        android:id="@+id/editText3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" 
        android:background="@drawable/my_shape_3"/>

</LinearLayout>
  

運(yùn)行效果如下

初學(xué)Android,使用Drawable資源之使用ShapeDrawable資源(十五)
這樣的效果看起來怪怪的,文本框的背景被弄的亂七八糟了


初學(xué)Android,使用Drawable資源之使用ShapeDrawable資源(十五)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 夜夜操国产 | 久久美女免费视频 | 久草在线在线观看 | 日韩在线 | 中文 | 99久久99这里只有免费的精品 | 四虎影视网站 | 亚洲欧洲视频在线观看 | 老司机深夜影院入口aaaa | 在线播放91| 极品女神西比尔久久精品 | 激情五月综合综合久久69 | 狠狠色欧美亚洲狠狠色五 | 站长推荐国产午夜免费视频 | 欧美日韩综合高清一区二区 | 亚洲精品国产第一区二区三区 | 精品日韩一区二区三区 | 久久视频这里只有精品 | 美女羞羞视频网站 | 四虎免费紧急入口观看 | 18视频在线观看 | 99热国产免费| 久久久亚洲欧洲国产 | 精品三级国产一区二区三区四区 | 色婷婷综合激情 | 91婷婷色 | 欧美成人免费观看久久 | 久久久91精品国产一区二区 | 一日本道加勒比高清一二三 | 天天干天天操天天碰 | 老司机观看精品一区二区 | 日本高中生一级乇片 | 99精品福利视频 | 国产欧美综合一区二区 | 久久精品国产一区二区三区日韩 | 久久黄色录像 | 免费日本黄色网址 | 天天综合天天看夜夜添狠狠玩 | 在线黄色影院 | 婷婷综合社区 | 精品福利 | 亚洲国产精品a一区二区三区 |