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.定义布局文件


    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

 android:id="@+id/View01"
  android:layout_width="fill_parent"
    android:layout_height="fill_parent"
 >




 

//你可以任意定义UI的显示了

你可能感兴趣的:(android)