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

android開發(fā)教程之view組件添加邊框示例

 更新時(shí)間:2014年02月17日 09:33:16   作者:  
這篇文章主要介紹了android開發(fā)中給view組件添加邊框的示例,需要的朋友可以參考下

給TextureView添加邊框(專業(yè)名詞為描邊),有三種解決方案:

1.設(shè)置一個(gè)9 patch 的,右邊框,中間是空的PNG。

2.自定義一個(gè)View,用Canvas畫個(gè)邊框。

3.用Android提供的ShapeDrawable來定義一個(gè)邊框。

個(gè)人比較建議采用第三種方式,原因是因?yàn)榈谌N只要寫XML,速度快,占用資源小,代碼編寫量也少,便于維護(hù)。

使用方法如下:

1.定義一個(gè)background.xml文件。

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
    android:width="2dp"
    android:color="#0000AA" />   
</shape> <span></span>

2.在View的src設(shè)置背景時(shí)使用就可以了。

復(fù)制代碼 代碼如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:gravity="center"
        android:src="@drawable/background"
        android:padding="2dp"> 
        <TextureView         
            android:layout_width="match_parent"                             
            android:layout_height="match_parent"/>
        <com.android.camera.ui.RotateLayout
            android:layout_width="wrap_content"
            android:layout_width="wrap_content">
            <TextView
                 android:layout_width="wrap_content"
                 android:layout_width="wrap_content"
                 android:textColor="#FFFFFF"
                 android:textSize="22sp"
                 android:background="#0000000"/>
       </com.android.camera.ui.RoateLayout>
</RelativeLayout>

需要注意的是我給TextureView的父容器RelativeLayout設(shè)置了Drawable,并設(shè)置了Padding。

相關(guān)文章

最新評論

塔城市| 新津县| 县级市| 文水县| 清苑县| 土默特右旗| 巴林左旗| 江津市| 通山县| 栖霞市| 泌阳县| 伽师县| 淮安市| 浦东新区| 潞西市| 金秀| 广宗县| 准格尔旗| 苏尼特左旗| 南宫市| 白银市| 枣强县| 玉屏| 平原县| 登封市| 金堂县| 肇东市| 皋兰县| 米脂县| 崇信县| 宝丰县| 行唐县| 锡林郭勒盟| 西青区| 额尔古纳市| 鹿邑县| 桂林市| 松潘县| 渑池县| 乌兰察布市| 康乐县|