简体   繁体   中英

Java scaling Image

thanks for reading! I have a real problem cencerning providing a image for different screen densities. The Bitmap at the top of the Screenshot is provided on a server. My App loads this PNG at startup and the PNG is loaded by

ImageView ivBanner = (ImageView) findViewById(R.id.iv_banner);
ivBanner.setImageBitmap(Statics.banner);   
ivBanner.setOnClickListener(Bannerlistener);

But as u can see there are some strange boarders between the image and the top/tabs. If I put the image in the drawable folder and load it by XML as src everything is OK, scalling is right and there are no borders. But the Problem is, that I can not load it by XML!

Anybody any hints for me? Again, thank you for reading and helping!

Greetings Andi

Screener: http://imageshack.us/photo/my-images/72/scaling.png/

edit: This worked for me after trying and trying:

<ImageView
        android:id="@+id/iv_banner"
        android:layout_width="fill_parent"
        android:layout_height="55dp" android:adjustViewBounds="true"              android:scaleType="fitCenter"/>

Thank you! If you see any Problems on this code please let me know.

try to use some attributes like this :

ivBanner.setScaleType(ImageView.ScaleType.FIT_XY);

else try

ivBanner.setScaleType(ImageView.ScaleType.FIT_END);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM