2015-03-30 167 views
1

請幫我解決一個奇怪的問題。我有三個圖像的簡單線性佈局,大小相同。在Android Studio設計中看起來很正常,但在設備上,第三個imageview具有不同的大小。如何解決它?附:圖像資源具有相同的尺寸佈局xml中的相同圖像尺寸 - 設備上的不同

部分:

Android中工作室
<LinearLayout android:layout_width="match_parent" 
           android:layout_height="60dp" 
           android:orientation="horizontal" 
           android:gravity="center" 
           android:layout_marginTop="16dp" 
           android:layout_marginBottom="16dp"> 
        <ImageView android:id="@+id/twitterlb" 
           android:layout_height="match_parent" 
           android:layout_width="60dp" 
           android:src="@drawable/tw_circle" android:scaleType="fitCenter"/> 
        <ImageView android:id="@+id/facebooklb" 
           android:layout_height="match_parent" 
           android:layout_width="60dp" 
           android:src="@drawable/fb_circle" android:scaleType="fitCenter" 
           android:layout_marginLeft="16dp" 
           android:layout_marginRight="16dp"/> 
        <ImageView android:id="@+id/linkedinlb" 
           android:layout_height="match_parent" 
           android:layout_width="60dp" 
           android:src="@drawable/in_circle" android:scaleType="fitCenter"/> 
       </LinearLayout> 

buttons looks same in Android studio

上設備:

on device

+0

嘗試爲所有三個ImageView提供'android:layout_height =「60dp」'。並給你的LinearLayout'android:layout_height =「wrap_content」'。這樣,你會考慮額外的保證金/填充DPS。 – 2015-03-30 18:53:57

+0

謝謝,但已經嘗試過,同樣的問題。也嘗試在不同的設備上運行和清理/重建項目,並重新安裝應用程序 – Anna 2015-03-30 18:58:20

+0

所以嘗試使用'android:background'而不是'android:src' – 2015-03-30 19:06:18

回答

0
<ImageView android:id="@+id/linkedinlb" 
        android:layout_height="match_parent" 
        android:layout_width="60dp" 
        android:background="@drawable/in_circle" 
        android:scaleType="fitXY"/> 

您可能會嘗試將scaleType更改爲fitXY

0

謝謝你們,我終於解決了這個問題。問題是:爲可繪製-MDPI,可繪製-xxhdpi,可繪製-nodpi,可繪製-xxxhdpi, 抽拉-HDPI,可繪製-LDPI,相同相似水庫但不同爲可繪製-xhdpi(5個像素透明幀)

相關問題