机器人,ImageView的舒展 [英] android, imageview stretch

查看:131
本文介绍了机器人,ImageView的舒展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的ImageView与绘制PNG填补显示(我不关心的比例)。然而,FILL_PARENT不工作,而据我所知没有任何背景被设置为一个RelativeLayout的?

问候

 的RelativeLayout
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:可点击=真
安卓的onClick =toggleAdvice   ImageView的
    机器人:ID =@ + ID / advice_view
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:SRC =@绘制/ pratbubbla_gron
    机器人:layout_alignParentTop =真
    机器人:layout_alignParentLeft =真


解决方案

我用来拉伸/编程shring ImageView的,大概这块code将帮助您:

  ImageView的ImageView的=新ImageView的(上下文);
    imageView.setAdjustViewBounds(真);
    imageView.setImageBitmap(位图);
    imageView.setMaxHeight(了maxHeight);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    layout.addView(ImageView的);

I'm trying to get my imageview with a drawable png to fill the display (I don't care about ratios). However, fill_parent doesn't work, and as far as I know there are no background to be set to a RelativeLayout?

Regards

RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:onClick="toggleAdvice"



   ImageView
    android:id="@+id/advice_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/pratbubbla_gron"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"

解决方案

I used to stretch/shring ImageView programmatically, probably this piece of code will help you:

    ImageView imageView=new ImageView(context);
    imageView.setAdjustViewBounds(true);
    imageView.setImageBitmap(bitmap);
    imageView.setMaxHeight(maxHeight);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    layout.addView(imageView);

这篇关于机器人,ImageView的舒展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆