这篇文章给大家介绍Android应用中如何将图片的单位进行转换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。ImageSwitcher: 图像查看器,好像是老组件了,今天先更一个基础的组件,后期如果有时间继续
这篇文章给大家介绍Android应用中如何将图片的单位进行转换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
ImageSwitcher:
图像查看器,好像是老组件了,今天先更一个基础的组件,后期如果有时间继续扩展.
那么图像查看器,就是和 windows 系统下的图片查看器比较类似.自带上一张和下一张的功能.
这个组件有以下几个特点,本人感觉:
该组件属于容器性质;
ImageSwitcher 本身继承了 FrameLayout, 也可以使用帧布局的一些属性.
在使用 ImageSwitcher 的时候,必须实现 ViewSwitcher.ViewFactory 的接口,然后通过复写 makeView() 方法来创建用于显示图片的 ImageView,并且 makeView()方法返回一个显示图片的 ImageView.
图片加载 ImageView 上的话,如果是本地资源的话,需要使用 setImageResource() 方法.
上面基本的原理大致描述清楚,下面上代码
XML 布局文件,这里面只有2个按钮和 ImageSwitcher 的组件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="Http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="horizontal"> <Button android:id="@+id/up_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上一张" /> <!-- 图像转换器--> <ImageSwitcher android:id="@+id/main_imageswitcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <Button android:id="@+id/down_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一张" /></LinearLayout>
--结束END--
本文标题: Android应用中如何将图片的单位进行转换
本文链接: https://www.lsjlt.com/news/224227.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0