2017-11-18 48 views
-1

我只想做一個簡單的圖像視圖,但是當我運行該應用程序時,會出現不必要的白色背景。我不想要那部分。任何解決方案圖像大小 - 如何?

the white part unecessary

,這裏是該圖像查看我的XML文件

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 


<ImageView 
    android:id="@+id/imageView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:src="@drawable/pot1"/> 
</LinearLayout> 
+0

檢查我答 – Prem

+0

下面你代替白色背景要做些什麼? – m0skit0

回答

1

如果你想堅持到屏幕頂部或添加scaleType屬性刪除gravity屬性fitCentercropCenter或如果你想讓它填滿屏幕,請使用fitXY

0

在代碼中使用 -

imgview.setScaleType(ScaleType.FIT_XY); 

或者在XML圖像視圖 -

android:scaleType="fitXY" 
+0

如果我這樣做,那麼我失去了我的寬度部分的圖像 – Meeyan