2015-12-24 46 views
0

我一直在一个应用程序工作了一段时间,现在创建一个拼图游戏。我正在测试各种尺寸和密度的屏幕。使用Krita我将拼贴图像缩小到110 x 110像素,以用于mdpi格式。奇怪的是,这个尺寸在我到目前为止用于测试的xhdpi模拟器中工作得很好,但是我创建的mdpi模拟器显着缩小了图像。虽然我可以为较小的屏幕密度创建较大的图像,但它无法理解我对android如何处理文档密度的理解。这些图像不应该放在较低的分辨率上吗?下面是布局文件的网格布局部分:屏幕分辨率与图像问题

<GridLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:columnCount="3" 
    android:rowCount="3" 
    android:id="@+id/TheGrid" 
    android:layout_centerInParent="true" 
    android:background="@color/background_floating_material_light" 
    android:animateLayoutChanges="true" 
    android:layout_toRightOf="@+id/title_inflater" 
    android:layout_toLeftOf="@+id/picture_inflator" 
    > 

    <ImageView 
     android:id="@+id/TopLeft" 
     android:clickable="true" 
     android:layout_column="0" 
     android:layout_row="0" 
     android:layout_gravity="fill" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 
    <ImageView 
     android:id="@+id/TopCenter" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="0" 
     android:layout_column="1" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 
    <ImageView 
     android:id="@+id/TopRight" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="0" 
     android:layout_column="2" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 


    <ImageView 
     android:id="@+id/CenterLeft" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="1" 
     android:layout_column="0" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 

    <ImageView 
     android:id="@+id/CenterCenter" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="1" 
     android:layout_column="1" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 
    <ImageView 
     android:id="@+id/CenterRight" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="1" 
     android:layout_column="2" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 

    <ImageView 
     android:id="@+id/BottomLeft" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="2" 
     android:layout_column="0" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 
    <ImageView 
     android:id="@+id/BottomCenter" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="2" 
     android:layout_column="1" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 
    <ImageView 
     android:id="@+id/BottomRight" 
     android:clickable="true" 
     android:layout_gravity="fill" 
     android:layout_row="2" 
     android:layout_column="2" 
     android:src="@drawable/star_trek_federation_emblem_9pc_1" 
     /> 

    <ImageView 
     android:id="@+id/mover" 
     android:layout_row="2" 
     android:layout_column="2" 
     android:visibility="invisible" 
     android:layout_gravity="fill" 
     /> 
</GridLayout> 

这是它的外观在预览(这是它的外观的xhdpi屏幕上):

enter image description here

但在MDPI屏幕看起来像:

enter image description here

我想知道为什么会这样,我只是一味adjus前t图像,但在创建各种模拟器和搜索网页的大部分时间里,我都陷入了困境。非常感激任何的帮助。

回答

1

1)第一种方式你可以从这个链接 https://romannurik.github.io/AndroidAssetStudio/创建图像的所有大小只需上传图片到这个网站,你会得到所有尺寸的图像对所有drawable.it可以帮助你在所有的大小调整。

,或者如果你不从第一种方式一样可以使用

此 第二种方式 要创建针对不同密度的图标,应遵循的2:4 6之间的缩放比率:3:4初级密度(分别为中,高,x高和xx高)。

例如,考虑启动器图标的大小指定为48x48 dp。

这意味着基准(MDPI)的资产是48×48像素,

和高密度(HDPI)资产应1.5倍基线在72x72像素,

和x高密度(XHDPI )资产应该是96x96像素的基线的2倍,以此类推。

注意:Android也支持资产大小为36x36像素的低密度(LDPI)屏幕,但您通常不需要创建此大小的自定义资产,因为Android会将您的HDPI资产有效缩小1/2到匹配预期的大小。

同样,对于XXHDPI资产大小应该是144x144像素。

来源:developer.android.com

+0

我很欣赏尝试,但这是直接从开发人员网站。这并不能解释为什么在mdpi屏幕上适当调整xldpi屏幕大小的图像会较小。我的理解是,较低分辨率的屏幕会散布较大密度的图像。 –