Android自定义控件使用declare-styleable 属性以及例子波浪,xmlns:android="http://schemas.android.com/apk/res/android"

reference指的是是从string.xml引用过来
flag是自己定义的,类似于 android:gravity="top"
dimension 指的是是从dimension.xml里引用过来的内容.注意,这里如果是dp那就会做像素转换

xmlns:android="http://schemas.android.com/apk/res/android" 什么意思:

xmlns: xml namespace

命名空间,没有这句话就不能设置 android:***** 等属性

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:wave="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.itep.wave.MainActivity">

    <View
        android:background="@color/colorAccent"

        android:layout_width="match_parent"
        android:layout_height="44dp"

猜你喜欢

转载自blog.csdn.net/qq_38998213/article/details/105044800