Android窗口小部件基础编写代码实例
作者:yaominghui 时间:2022-05-09 20:58:00
实现窗口小部件,访问手机储存卡指定目录中的图片文件,然后随机选择一张在窗口的小部件中显示。图片路径使用List存储,适合初级Android学习者参考。本系统无服务,不能保证进程长存。
新建一个空的布局项目,然后新建一个Widget,如图所示:
在新建的xml和java实现类中进行编写即可。
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:id="@+id/picture_widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/zhizhuxia" />
<TextView
android:id="@+id/change_picture"
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>
来源:https://www.cnblogs.com/lgqrlchinese/p/10963781.html
标签:Android,窗口,部件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#加密解密文件小工具实现代码
2021-09-21 07:31:41
![](https://img.aspxhome.com/file/2023/4/86954_0s.png)
单点登录的三种方式和JWT的介绍与使用
2023-05-19 22:10:59
IDEA标签tabs多行显示的设置
2023-09-18 06:58:08
![](https://img.aspxhome.com/file/2023/9/81999_0s.jpg)
Fluent Mybatis让你摆脱Xml文件的技巧
2023-10-02 18:31:00
![](https://img.aspxhome.com/file/2023/0/91090_0s.jpg)
基于Java实现经典蜘蛛纸牌游戏
2021-09-06 15:22:57
![](https://img.aspxhome.com/file/2023/8/79878_0s.png)
C#实战之备忘录的制作详解
2023-08-13 02:17:21
![](https://img.aspxhome.com/file/2023/8/116638_0s.jpg)
springboot项目访问静态资源的配置代码实例
2021-11-16 02:07:49
JavaWeb ServletConfig作用及原理分析讲解
2021-11-09 05:50:54
SpringMVC 如何使用注解完成登录拦截
2023-11-18 02:20:11
springMVC利用FastJson接口返回json数据相关配置详解
2023-02-24 10:51:58
Spring ApplicationListener源码解析
2021-08-10 08:11:12
![](https://img.aspxhome.com/file/2023/7/116827_0s.png)
javax.mail.SendFailedException: Sending failed问题原因
2021-08-07 20:00:57
手写redis@Cacheable注解 参数java对象作为key值详解
2022-04-26 11:30:36
![](https://img.aspxhome.com/file/2023/8/83458_0s.png)
android 实现控件左右或上下抖动教程
2023-03-19 17:02:07
C#中ManualResetEvent实现线程的暂停与恢复
2021-06-20 14:59:24
![](https://img.aspxhome.com/file/2023/4/116454_0s.png)
SpringCloud Finchley+Spring Boot 2.0 集成Consul的方法示例(1.2版本)
2023-09-02 13:07:36
![](https://img.aspxhome.com/file/2023/9/58329_0s.png)
json格式数据分析工具PageElement类分享(仿Session写法)
2023-09-16 16:04:32
跳一跳自动跳跃C#代码实现
2023-02-19 11:12:46
![](https://img.aspxhome.com/file/2023/3/69203_0s.png)
IDEA插件之彩虹括号Rainbow Brackets使用介绍
2022-03-14 09:09:51
![](https://img.aspxhome.com/file/2023/5/98125_0s.png)
C#中WPF内存回收与释放LierdaCracker的实现
2022-11-13 00:15:44