详解Android自定义控件属性

2019-12-10 19:06:20王振洲

 

<LinearLayout xmlns:android="http://www.easck.com/apk/res/android"
  xmlns:tools="http://www.easck.com/tools"
  xmlns:ldm="http://www.easck.com/apk/res/com.ldm.learn"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#f6f6f6"
  android:orientation="vertical"
  android:padding="10dp" >

  <com.ldm.learn.CustomTextView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:text="自定义TextView"
    ldm:custom_color="#333333"
    ldm:custom_size="35sp" />

</LinearLayout>

布局说明:

详解Android自定义控件属性

通过以上几步就可以实现我们想要的自定义属性效果(用自定义属性设置文字大小及颜色)啦!



注:相关教程知识阅读请移步到Android开发频道。