Android自定义View设定到FrameLayout布局中实现多组件显示的方法 分享
如果想在自定义的View上面显示Button 等View组件需要完成如下任务
1.在自定义View的类中覆盖父类的构造(注意是2个参数的)
public class MyView2 extends View{public MyView2(Context context,AttributeSet att)
{super(context,att);
}
public void onDraw(Canvas c)
{ // 这里绘制你要的内容
}
}
2.定义布局文件
< ?xml version="1.0" encoding="utf-8"?>< FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< com.lovose.MyView2
android:id="@+id/View01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< /com.lovose.MyView2>
< AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_width="wrap_content" Android:layout_height="wrap_content">
< Button android:text="Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="100dip" Android:layout_y="100dip">< /Button>
< /AbsoluteLayout>
< /FrameLayout>
//哈哈,你可以任意定义UI的显示了
您可能感兴趣的文章:
- Android自定义View设定到FrameLayout布局中实现多组件显示
- Android开发中自定义View设定到FrameLayout布局中实现多组件显示
- Android开发中自定义View设定到FrameLayout布局中实现多组件显示
- android 让TextView支持的Html标签实现自定义时钟显示组件DigitalClock
- 在Android中,可以自定义类,继承ViewGroup等容器类,以实现自己需要的布局显示。
- Android自定义TextView实现文字图片居中显示的方法
- 解析在Android中为TextView增加自定义HTML标签的实现方法
- android之自定义ViewGroup和自动换行的布局的实现
- android之自定义ViewGroup和自动换行的布局的实现
- android文本组件textView属性autolink设置为web,显示网址的处理方法
- 【Android Training - Performance】提高显示布局文件的性能[Lesson 3 - 按需载入视图(ViewStub的使用方法)]
- android之自定义ViewGroup和自动换行的布局的实现
- android自定义RadioGroup可以添加多种布局的实现方法
- android之自定义ViewGroup和自动换行的布局的实现
- 实现自定义view(2):仿Android QQ多屏幕显示ListView的效果
- android之自定义ViewGroup和自动换行的布局的实现
- Android自定义ViewGroup自动换行实现滑动任意布局及事件处理效果
- Android中的自定义Adapter(继承自BaseAdapter)——与系统Adapter的调用方法一致——含ViewHolder显示效率的优化
- android 腾讯微博分享功能实现及自定义webview认证
- Android开发:setContentView切换界面,自定义带CheckBox的ListView显示SQlite条目-----实现