国产探花免费观看_亚洲丰满少妇自慰呻吟_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的顯示了

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 张北县| 进贤县| 兴城市| 宽甸| 格尔木市| 连江县| 资阳市| 霍邱县| 麦盖提县| 海口市| 丽江市| 特克斯县| 满城县| 兴安盟| 综艺| 昔阳县| 报价| 涞源县| 双峰县| 含山县| 西丰县| 林周县| 湘潭市| 房山区| 永平县| 徐州市| 沙坪坝区| 大姚县| 吉隆县| 宜君县| 河北省| 孟村| 龙南县| 太康县| 开平市| 长垣县| 嵊泗县| 页游| 六枝特区| 临沭县| 千阳县|