国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android自定義View設定到FrameLayout布局中實現多組件顯示的方法 分享

2020-04-11 12:19:58
字體:
來源:轉載
供稿:網友

如果想在自定義的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的顯示了

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汕头市| 双桥区| 韶山市| 公主岭市| 九江县| 呼伦贝尔市| 柳河县| 郑州市| 肇源县| 正镶白旗| 屏东市| 四平市| 旬邑县| 南宫市| 女性| 呼玛县| 蒙城县| 葫芦岛市| 高密市| 沭阳县| 怀安县| 藁城市| 阿勒泰市| 黄石市| 武邑县| 安陆市| 延安市| 秦皇岛市| 新龙县| 家居| 台湾省| 大宁县| 阿鲁科尔沁旗| 彝良县| 汝南县| 平原县| 吴忠市| 湖口县| 内黄县| 宜兰县| 武强县|