简体   繁体   中英

imageview not set full screen

I set image view to full screen but it doesn't work: there is some space in between left and right side. How to set the imageview to full screen?

this is my XML code:

<?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">
    <ImageView android:id="@+id/imageView"  
            android:layout_width="fill_parent"  
            android:layout_height="fill_parent">  
   </ImageView>  
</LinearLayout>

use android:scaleType="fitXY" in your xml:

<ImageView android:id="@+id/imageView"  
       android:layout_width="match_parent"  
       android:layout_height="match_parent"  
       android:scaleType="fitXY"
/>  

Try one of following options

android:scaleType="CENTER_CROP" 

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).

android:scaleType="CENTER_INSIDE"

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).

android:scaleType="fitXY"

Scale in X and Y independently, so that src matches dst exactly.

If you don't care about ratio

ImageView imageView=new ImageView(context);
imageView.setAdjustViewBounds(false);

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