自定义控件想在布局文件中使用如下方法
1 定义自己的控件类这里使用pqw.view.MyView类
2 在布局文件中定义格式如下
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<pqw.view.MyView
android:id="@+id/myview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
自定义的控件在布局文件中使用时需要指定完整的类名,修改类定义源码可以在布局文件中实时更新。
自定义控件在布局文件中使用的方法
最新推荐文章于 2021-05-27 21:15:36 发布