我在android布局设计的分辨率/密度方面遇到了一些问题。
例如,我在AVD4“480x800 hdpi (Normal-Land)中使用like base size,结果如下所示

对于AVD7“800x600 hdpi (Large-Land)中的相同布局,如下所示

这是布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/fondo_main"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/tittle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_marginBottom="15dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:background="@color/fondo_main"
android:text="Menu Principal"
android:textColor="@color/azul_asde"
android:textSize="25sp" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/roundcorners"
android:gravity="center" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/buttonnewreg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/nuevopac3" />
<ImageView
android:id="@+id/buttonviewreg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/verpac4" />
<ImageView
android:id="@+id/buttonconfig"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/config5" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/Textheadwelcome2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Nueva ficha"
android:textColor="@color/azul_asde"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/Textheadwelcome2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Ver fichas"
android:textColor="@color/azul_asde"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/Textheadwelcome2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Configuración"
android:textColor="@color/azul_asde"
android:textSize="16sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</LinearLayout>图像的大小是100x100px,我怀疑如何选择图像的像素大小作为HDPI的基础,并从那里增加到xhdpi或减少到mdpi
面对同样类别的像素密度(hdpi),你可以控制图像的大小吗?,因为很明显,问题是屏幕分辨率是480x800而不是800x1200。尽管是800x1200,但使用hdpi可以清楚地看到图像较小
谢谢
发布于 2014-05-12 20:02:27
您观察到的结果是两个屏幕具有大致相同的dpi (因此使用相同的图像分辨率)。你还会注意到字体没有缩放,因为7英寸的平板电脑比4英寸的手机有更多的屏幕空间。
然而,很难在所有设备上实现完全相同的外观。并不是所有的设备都有相同的纵横比和方向。
我假设您不想手动设置每个屏幕元素;也许您应该只关注图像本身,并使用android:scaleType="FIT_CENTER“修复它们。但是,这可能会由于调整位图大小而导致一些模糊。
另一种选择是使用矢量图像,例如带有androidSVG库的SVG,以减少模糊。
https://stackoverflow.com/questions/23606766
复制相似问题