zoukankan      html  css  js  c++  java
  • 自定义属性,资源文件attrs.xml

    1.attrs.xml中写:在values文件夹下。

      

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <declare-styleable name="TestAttr">
            <attr name="name" format="reference" />
            <attr name="age">
                <flag name="child" value="10" />
                <flag name="young" value="18" />
                <flag name="oldman" value="60" />
            </attr>
            <attr name="textSize" format="dimension" />   
        </declare-styleable>
    </resources>

    2.布局文件中写:

      

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:attrstest="http://schemas.android.com/apk/res/com.arlos.attrstest"
     4     android:layout_width="fill_parent"
     5     android:layout_height="fill_parent"
     6     android:orientation="vertical" >s
     7 
     8     <com.arlos.attrstest.MyTestView
     9         android:id="@+id/tvTest"
    10         android:layout_width="fill_parent"
    11         android:layout_height="wrap_content"
    12          attrstest:name="@string/myname" 
    13          android:gravity="top"
    14          attrstest:age="young"
    15          attrstest:textSize="@dimen/aa"
    16         android:text="@string/hello" />
    17 
    18 </LinearLayout>
    View Code
  • 相关阅读:
    列表和元组
    UVM宏
    UVM中重要函数
    组合模式(composite)
    装饰器模式(Decorator)
    适配器模式(Adapter)
    桥接模式
    原型模式(prototype)
    单例模式(singleton)
    UML类图
  • 原文地址:https://www.cnblogs.com/xxwn/p/4717239.html
Copyright © 2011-2022 走看看