Android窗口小部件基礎(chǔ)編寫代碼實例
實現(xiàn)窗口小部件,訪問手機(jī)儲存卡指定目錄中的圖片文件,然后隨機(jī)選擇一張在窗口的小部件中顯示。圖片路徑使用List存儲,適合初級Android學(xué)習(xí)者參考。本系統(tǒng)無服務(wù),不能保證進(jìn)程長存。
新建一個空的布局項目,然后新建一個Widget,如圖所示:
在新建的xml和java實現(xiàn)類中進(jìn)行編寫即可。
picture_widget.xml文件如下:
<RelativeLayout xmlns:android='http://schemas.android.com/apk/res/android' android:layout_width='match_parent' android:layout_height='match_parent' android:padding='@dimen/widget_margin'> <ImageView android: android:layout_width='match_parent' android:layout_height='match_parent' android:src='http://www.aoyou183.cn/bcjs/@drawable/zhizhuxia' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='' android:textSize='10dp' android:gravity='right|bottom' android:layout_marginRight='2dp' android:layout_marginBottom='2dp'/></RelativeLayout>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Kotlin + Flow 實現(xiàn)Android 應(yīng)用初始化任務(wù)啟動庫2. 基于javascript處理二進(jìn)制圖片流過程詳解3. Gitlab CI-CD自動化部署SpringBoot項目的方法步驟4. ajax請求添加自定義header參數(shù)代碼5. 使用python 計算百分位數(shù)實現(xiàn)數(shù)據(jù)分箱代碼6. ASP基礎(chǔ)知識VBScript基本元素講解7. ASP中解決“對象關(guān)閉時,不允許操作?!钡脑幃悊栴}……8. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)9. 教你如何寫出可維護(hù)的JS代碼10. 使用Python和百度語音識別生成視頻字幕的實現(xiàn)
