Android自定義View設(shè)定到FrameLayout布局中實(shí)現(xiàn)多組件顯示的方法 分享
如果想在自定義的View上面顯示Button 等View組件需要完成如下任務(wù)
1.在自定義View的類中覆蓋父類的構(gòu)造(注意是2個(gè)參數(shù)的)
public class MyView2 extends View{
public MyView2(Context context,AttributeSet att)
{super(context,att);
}
public void onDraw(Canvas c)
{ // 這里繪制你要的內(nèi)容
}
}
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的顯示了
相關(guān)文章
Android實(shí)現(xiàn)隨意拖動(dòng)View效果的實(shí)例代碼
這篇文章主要介紹了Android實(shí)現(xiàn)隨意拖動(dòng)View效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07Android編程實(shí)現(xiàn)在Bitmap上涂鴉效果
這篇文章主要介紹了Android編程實(shí)現(xiàn)在Bitmap上涂鴉效果的方法,涉及Android界面布局,事件響應(yīng)及Bitmap操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12Android studio 4.1打包失敗和插件錯(cuò)誤提示的解決
這篇文章主要介紹了Android studio 4.1打包失敗和插件錯(cuò)誤提示的解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10Android中通過view方式獲取當(dāng)前Activity的屏幕截圖實(shí)現(xiàn)方法
這篇文章主要介紹了Android中通過view方式獲取當(dāng)前Activity的屏幕截圖實(shí)現(xiàn)方法,本文方法相對(duì)簡(jiǎn)單,容易理解,需要的朋友可以參考下2014-09-09Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)
這篇文章主要給大家介紹了Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-01-01Android Selector獲取焦點(diǎn)后文本背景修改的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android Selector獲取焦點(diǎn)后文本背景修改的實(shí)現(xiàn)代碼,本文通過demo展示和實(shí)現(xiàn)代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11Android小掛件(APP Widgets)設(shè)計(jì)指導(dǎo)
這篇文章主要為大家詳細(xì)介紹了Android小掛件APP Widgets設(shè)計(jì)指導(dǎo),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12android仿知乎標(biāo)題欄隨ScrollView滾動(dòng)變色
這篇文章主要為大家詳細(xì)介紹了android仿知乎標(biāo)題欄隨ScrollView滾動(dòng)變色,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06