Android窗口小部件基礎(chǔ)編寫代碼實例
實現(xiàn)窗口小部件,訪問手機儲存卡指定目錄中的圖片文件,然后隨機選擇一張在窗口的小部件中顯示。圖片路徑使用List存儲,適合初級Android學習者參考。本系統(tǒng)無服務(wù),不能保證進程長存。
新建一個空的布局項目,然后新建一個Widget,如圖所示:
在新建的xml和java實現(xià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.leifengta.com.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)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )2. PHP基礎(chǔ)之生成器4——比較生成器和迭代器對象3. ASP新手必備的基礎(chǔ)知識4. Docker 啟動Redis 并設(shè)置密碼的操作5. asp文件用什么軟件編輯6. 通過IEAD+Maven快速搭建SSM項目的過程(Spring + Spring MVC + Mybatis)7. JS中6個對象數(shù)組去重的方法8. vue+element開發(fā)一個谷歌插件的全過程9. 利用CSS制作3D動畫10. Vue axios獲取token臨時令牌封裝案例

網(wǎng)公網(wǎng)安備