xml中的相同图像尺寸 - 设备上的不同

xml中的相同图像尺寸 - 设备上的不同

问题描述:

请帮我解决一个奇怪的问题。我有三个图像的简单线性布局,大小相同。在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

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

您可能会尝试将scaleType更改为fitXY

谢谢你们,我终于解决了这个问题。问题是:为可绘制-MDPI,可绘制-xxhdpi,可绘制-nodpi,可绘制-xxxhdpi, 抽拉-HDPI,可绘制-LDPI,相同相似水库但不同为可绘制-xhdpi(5个像素透明帧)