簡體   English   中英

imageview未設置全屏

[英]imageview not set full screen

我將圖像視圖設置為全屏但不起作用:左側和右側之間有一些空間。 如何將imageview設置為全屏?

這是我的XML代碼:

<?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>

在你的xml中使用android:scaleType="fitXY"

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

請嘗試以下選項之一

android:scaleType="CENTER_CROP" 

均勻縮放圖像(保持圖像的縱橫比),使圖像的尺寸(寬度和高度)等於或大於視圖的相應尺寸(減去填充)。

android:scaleType="CENTER_INSIDE"

均勻縮放圖像(保持圖像的縱橫比),使圖像的尺寸(寬度和高度)等於或小於視圖的相應尺寸(減去填充)。

android:scaleType="fitXY"

獨立地在X和Y中縮放,以便src完全匹配dst。

如果你不關心比例

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM