
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="vertical" > <FrameLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:padding="4dp" > <FrameLayout androID:ID="@+ID/page_layout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:visibility="visible" > <ImageVIEw androID:ID="@+ID/image" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:adjustVIEwBounds="true" androID:scaleType="fitCenter" androID:src="@drawable/some_image" /> </FrameLayout> </FrameLayout></linearLayout>
ImageVIEw的宽度是match_parent,它的所有祖先都是相同的.布局设计器显示ImageVIEw的尺寸跨越整个宽度,但内部图像不是.
编辑:图像正确缩放.问题是列表视图行的高度使得宽度无法缩放到正确的大小.如果我使用fitXY,它会缩放宽度,但纵横比不正确.
有任何想法吗?
谢谢.
如果不创建自定义视图,我找不到任何方法来实现这一目标.简而言之,自定义视图将其自身的尺寸设置为其后面的可绘制的实际(非缩放)尺寸.
public class ResizableImageVIEw extends ImageVIEw { public static interface OnSizeChangedListener { voID onSizeChanged(int wIDth,int height); } private OnSizeChangedListener onSizeChangedListener = null; public ResizableImageVIEw(Context context,AttributeSet attrs) { super(context,attrs); } @OverrIDe protected voID onMeasure(int wIDthMeasureSpec,int heightmeasureSpec) { int wIDth = MeasureSpec.getSize(wIDthMeasureSpec); int height = wIDth * getDrawable().getIntrinsicHeight() / getDrawable().getIntrinsicWIDth(); setMeasuredDimension(wIDth,height); if (onSizeChangedListener != null) { onSizeChangedListener.onSizeChanged(wIDth,height); } } public voID setonSizeChangedListener(OnSizeChangedListener Listener) { this.onSizeChangedListener = Listener; }} 在我的情况下,我需要获取调整大小的值,以便调整其他视图的大小,从而调整侦听器接口.
总结以上是内存溢出为你收集整理的android – ListView中的ImageView扩展了最大宽度全部内容,希望文章能够帮你解决android – ListView中的ImageView扩展了最大宽度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)