Android自定义view自定义属性怎么使用,请牛人指导
Android自定义view自定义属性如何使用,请牛人指导
一、如果定义时候这样定义如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="shelfLayerCenter" format="reference" />
</resources>
二、 使用如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:attr="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MainActivity" >
<com.soso.xs.ui.view.View_BookShelfList
android:layout_width="fill_parent"
android:layout_height="fill_parent"
attr:shelfLayerCenter ="@drawable/bookshelf_layer_center" />
</RelativeLayout>
三、请大神指导如何在自定义的view中取值,万分感谢谢!
联系邮箱hanjchao@foxmail.com
如哪位大哥有更好办法欢迎指点小弟,嘿嘿
另xmlns:attr="http://schemas.android.com/apk/res-auto"
中res-auto是自动匹配res中的资源,是没有错误的哦,网上的一致说法都是后面加自己的包名,这是另外的一种写法,只是小弟现在不清楚如何取值,现来求教,希望能共同解决这个问题,嘻嘻
另以下为小弟反编译ireader的定义和使用,但小弟未找到取值部分,望牛人指点,谢谢!
定义:
使用:
------解决方案--------------------
我就看看 不说话
一、如果定义时候这样定义如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="shelfLayerCenter" format="reference" />
</resources>
二、 使用如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:attr="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MainActivity" >
<com.soso.xs.ui.view.View_BookShelfList
android:layout_width="fill_parent"
android:layout_height="fill_parent"
attr:shelfLayerCenter ="@drawable/bookshelf_layer_center" />
</RelativeLayout>
三、请大神指导如何在自定义的view中取值,万分感谢谢!
联系邮箱hanjchao@foxmail.com
如哪位大哥有更好办法欢迎指点小弟,嘿嘿
另xmlns:attr="http://schemas.android.com/apk/res-auto"
中res-auto是自动匹配res中的资源,是没有错误的哦,网上的一致说法都是后面加自己的包名,这是另外的一种写法,只是小弟现在不清楚如何取值,现来求教,希望能共同解决这个问题,嘻嘻
另以下为小弟反编译ireader的定义和使用,但小弟未找到取值部分,望牛人指点,谢谢!
定义:
使用:
------解决方案--------------------
我就看看 不说话