android图片适应,android图片自适应屏幕大小

Android 如何让图片自适应WebView大小

在android4.0的版本之前是可以通过webView的一个属性设置图片大小自适应的,但是在4.0之后该属性设置无效,现在解决的办法是通过得到html中的Img标签,然后在html中插入javascript语言,修改img的属性

成都创新互联公司成立于2013年,先为乐昌等服务建站,乐昌等地企业,进行企业商务咨询服务。为乐昌企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

android 图片大小适应屏幕大小

自己处理bitmap

把屏幕分辨率上传,让后端处理返回适应大小的图片

android怎么设置自适应大小的背景图片

需要给你的ImageView布局加上Android:adjustViewBounds="true"

ImageView android:id="@+id/test_image"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:scaleType="fitXY"

android:adjustViewBounds="true"

android:layout_gravity="center"

android:contentDescription="@string/app_name"

android:src="@drawable/ic_launcher" /

然后,在代码里设置ImageView.最大宽度和最大高度,因为adjustViewBounds属性只有在设置了最大高度和最大宽度后才会起作用

int screenWidth = getScreenWidth(this);

ViewGroup.LayoutParams lp = testImage.getLayoutParams();

lp.width = screenWidth;

lp.height = LayoutParams.WRAP_CONTENT;

testImage.setLayoutParams(lp);

testImage.setMaxWidth(screenWidth);

testImage.setMaxHeight(screenWidth * 5); 这里其实可以根据需求而定,我这里测试为最大宽度的5倍

[img]

android如何设置图片自适应控件大小

ImageView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/ic_launcher" /

宽度和高度使用fill_parent (填充父窗体)

fill_parent 可以使控件充满父控件,也就是你说的自动使用图片控件外的控件大小。

android 图片大小如何设置可以自适应不同分辨率

不知道你什么情况下要让图片自适应不通过分辨率。给你举个例子吧,希望对你有所帮助!当你把图片塞到imageView中时,布局注意

不要把值定死 比如:

android:layout_width="100dp"

android:layout_height="90dp"

直接给他

android:layout_width="fill_parent"

android:layout_height="wrap_content"

这样 ,才能适应你分辨率。

还有就是drawable_hdpi ,ldpi,mdpi分别代表不同分辨率drawable_hdpi(800*480),ldpi(480*320),mdpi(320*240),你自己放图片时注意了。


标题名称:android图片适应,android图片自适应屏幕大小
转载来源:http://lszwz.com/article/dsopijo.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款