使用Android Stuio自定义属性

来源:互联网 发布:陈欣怡药检呈阳性知乎 编辑:程序博客网 时间:2024/06/01 21:03


在使用Android Studio创建自定义控件的自定义属性时,需要声明命名空间,


如:

<LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    xmlns:round = "http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    tools:context="com.example.hm.myimooc.RoundRectXfermodActivity">    <com.example.hm.myimooc.RoundRectXfermodeView        android:id="@+id/fermodView"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        round:roundbitmap ="@drawable/test3"/></LinearLayout>

在eclipse中声明命名空间是

xmlns:自定义字段 = "http://schemas.android.com/apk/你的应用的包名"



但是在Android Studio中

<span style="font-family: Arial, Helvetica, sans-serif;">xmlns:自定义字段 = "http://schemas.android.com/apk/res-auto"</span>


xmlns:自定义字段 = "http://schemas.android.com/apk/你的应用的包名"

0 0
原创粉丝点击