2013-09-30 33 views
3

我知道這已經在stackoverflow中問了幾次;我徒勞地嘗試了所有的答案。我在我的android應用程序中有一個自定義的imageview(用於滾動/縮放)。我以編程方式將圖像設置爲在圖像視圖中顯示(因此,IDE中的圖像視圖爲空)。不過,我嘗試,似乎有一些填充左邊的&頂部的imageview無法刪除。請幫忙。這是代碼(以下是我從stackoverflow試過的一個可能的選項) 由於我的觸摸/縮放代碼取決於矩陣縮放類型,因此無法從矩陣更改縮放類型。android:make imageview全屏大小

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context=".ActivityHome" > 

<myTouchImageView 
android:id="@+id/imgView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:layout_marginLeft="0dp" 
android:layout_marginTop="0dp" 
android:scaleType="matrix" /> 

</RelativeLayout> 

然而,這是我所得到的:

enter image description here

回答

7

1更改android:scaleType="matrix"android:scaleType="fitXY"這意味着圖像將被拉伸以適應所有父級(ImageView)的邊,但如果要使分辨率保持爲android:scaleType="centerInside",則會更改其分辨率。

+0

這是不可能@ 3amoura因爲我的觸摸/縮放代碼取決於矩陣縮放類型。 – Jean

+0

1-您是否可以在設置imageView圖像的位置添加java代碼?2-在RelativeLayout中刪除方向。 3-這個屏幕是從eclipse IDE還是從手機拍攝的,因爲從eclipse來看,當使用ScaleType時它並不準確 –