android, imageview stretch

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"

Answers


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);

All View types have android:background, including RelativeLayout. No need for an ImageView, although I can't see any reason for your one to not fill the parent.


Need Your Help

Why ever declare members public instead of published?

delphi rtti

Declaring members as published has advantages over public:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.