Android ImageView ScaleType 和项目高度

Android ImageView ScaleType and item height(Android ImageView ScaleType 和项目高度)

本文介绍了Android ImageView ScaleType 和项目高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Things looked quite simple first but in the end the result is not good. I have an image which has a width larger than screen's width. So I need to scale it down in my imageview. I looked over the ScaleType options and tried them all but none is ok. First "center" only displays the image centered on the layout, no scaling done. "fitCenter" scales the image to fit in my layout but has a major drawback: the height of the item remains as it would have the large image in it. Take a look at the second screen in the attached image. How can I force the list item, to reduce its height to wrap both the text and the image ?

解决方案

Use the scaletype which seems best to you ( I guess you like what you see with fitCenter). The additional thing that you must do is

android:adjustViewBounds="true"

in your ImageView.

or you could go with FitXY but sometimes the result is not exactly what you want.

这篇关于Android ImageView ScaleType 和项目高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android ImageView ScaleType 和项目高度

基础教程推荐