2016-03-05 76 views
0

我創建了一個android應用程序。現在,當方向爲垂直方向的圖像加載罰款,這是我希望它喜歡這個 vertical OrientationImageView的圖像在水平方向上定位錯誤

` 但是當我打開設備水平這一形象被設定在imageview的左下角的正確方法 horizontal Orientation

的XML爲ImageView的是如下面`

 <ImageView 
      android:id="@+id/backdrop" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scaleType="matrix" 
      android:fitsSystemWindows="true" 
      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_collapseMode="pin" /> 

what is the reason causing this behavior ?? is it due to機器人:scaleType = 「矩陣」`屬性??任何幫助將不勝感激。

回答

0

由於ImageView的scaleType,如果您希望圖像填充整個容器,則需要使用不同的scaleType(如fillXY或CenterCrop)。

如果你想掌握這個主題,你可以檢查this文章比較每個scaleType,並決定哪一個適合您的最佳需求。

+0

我真正想要的是,圖像的左上角應該與imageview的左上角重合,因爲海報比設備屏幕大得多。任何想法如何做到這一點? – Infamous

+0

嘗試用fitStart –

+0

nop bro ..沒有工作,實際上使情況變得更糟糕..l0 – Infamous

0

Matrix可能不是你想要使用的。試試centerInsidecenterCrop,看看你最喜歡哪一個。其他變化可以發現here

+0

沒有任何值,如CENTER_INSIDE或CENTER_CROP – Infamous

+0

@Infamous對不起,指的是設置它的程序化方式,調整了我的文章 –

+0

你是否知道圖像的左上角應該如何與imageview的左上角重合,因爲海報是比相當大的設備screeen.when設備是垂直'android:scaleType =「矩陣」'正是我想要做的 – Infamous