Android窗口小部件基礎(chǔ)編寫(xiě)代碼實(shí)例
實(shí)現(xiàn)窗口小部件,訪問(wèn)手機(jī)儲(chǔ)存卡指定目錄中的圖片文件,然后隨機(jī)選擇一張?jiān)诖翱诘男〔考酗@示。圖片路徑使用List存儲(chǔ),適合初級(jí)Android學(xué)習(xí)者參考。本系統(tǒng)無(wú)服務(wù),不能保證進(jìn)程長(zhǎng)存。
新建一個(gè)空的布局項(xiàng)目,然后新建一個(gè)Widget,如圖所示:
在新建的xml和java實(shí)現(xiàn)類中進(jìn)行編寫(xiě)即可。
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.intensediesel.com/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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 在Android中使用WebSocket實(shí)現(xiàn)消息通信的方法詳解2. python matplotlib:plt.scatter() 大小和顏色參數(shù)詳解3. Yii2.0引入CSS,JS文件方法4. JSP數(shù)據(jù)交互實(shí)現(xiàn)過(guò)程解析5. Python importlib動(dòng)態(tài)導(dǎo)入模塊實(shí)現(xiàn)代碼6. vue使用webSocket更新實(shí)時(shí)天氣的方法7. 淺談python出錯(cuò)時(shí)traceback的解讀8. android studio 打包自動(dòng)生成版本號(hào)與日期,apk輸入路徑詳解9. Nginx+php配置文件及原理解析10. JavaMail 1.4 發(fā)布
