开发者

Bitmap Size is wrong

Hy!

The size of the Bitmap in the imageview doesn't look like 10x10

My Code:

iv = (ImageView) findViewById(R.id.imageViewPizza);
        iv.setMaxHeight(10);
        iv.setMaxWidth(10);

Screenshot:

Bitmap Size is wrong

The Image is lager than 10x10

Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:orientation="vertical">
    <TextView android:text="Name" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <MultiAutoCompleteTextView android:id="@+id/multiAutoCompleteTextView1" android:layout_height="wrap_content" android:text="" android:layout_width="fill_parent"></MultiAutoCompleteTextView>

    <TextView android:text="Bewertung" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <RatingBar android:id="@+id/ratingBar1" android:layout_width="wrap_content" android:layout_height="wrap_content"></RatingBar>
    <TextView android:text="Foto hinzufügen" android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <ImageView android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_width="wrap_content" android:id="@+id/imageViewPizza" &g开发者_StackOverflow社区t;</ImageView>
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent">
        <Button android:text="hinzufügen" android:layout_height="wrap_content" android:id="@+id/bt_addform" android:layout_alignParentBottom="true" android:layout_width="fill_parent"></Button>
    </RelativeLayout>
</LinearLayout>

Please help


You have both layout_width and layout_height set to wrap_content, in addition to setting explicit values for width and height. Instead, you should just set layout_width and layout_height to some number value. See this link: http://developer.android.com/guide/practices/screens_support.html


Set your desired width then add a scaleType mode. I would try fitXY.

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html


Try setting theLayoutParams of ImageView like this.

iv = (ImageView) findViewById(R.id.imageViewPizza);
iv.setLayoutParams(new LayoutParams(10,10));

It will set the width & height related to view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜