Android 不同的屏幕分辨率在平板电脑(1024x768)上显示良好,但在手机(800x480)上显示不好
我的Android应用程序有问题。当我使用分辨率为1024x768的hp touchpad时,一切看起来都正常。但是,当我在800x480(Desire HD)上测试时,出现了以下情况: 这是我的XML文件:Android 不同的屏幕分辨率在平板电脑(1024x768)上显示良好,但在手机(800x480)上显示不好,android,screen,Android,Screen,我的Android应用程序有问题。当我使用分辨率为1024x768的hp touchpad时,一切看起来都正常。但是,当我在800x480(Desire HD)上测试时,出现了以下情况: 这是我的XML文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_widt
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutH1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:orientation="vertical"
android:weightSum="1" >
<EditText
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:layout_weight=".50"
/>
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:layout_weight=".50"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH3"
android:layout_width="fill_parent"
android:layout_height="100sp"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/buttonClear"
style="@style/ButtonText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/custombuttonred"
android:text="@string/clear"
android:layout_weight=".40"
android:textSize="50sp" />
<ImageButton
style="@style/ButtonText"
android:id="@+id/c101_image"
android:layout_width="40sp"
android:layout_height="100sp"
android:scaleType="centerInside"
android:background="@drawable/cloud101"
android:layout_weight=".20" />
<Button
android:id="@+id/buttonBackspace"
style="@style/ButtonText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/custombuttonred"
android:text="@string/backspace"
android:layout_weight=".40"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH2"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_weight=".25"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button1"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="@string/b1"
android:textSize="110sp" />
<Button
android:id="@+id/button2"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="2"
android:textSize="110sp" />
<Button
android:id="@+id/button3"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="3"
android:textSize="110sp" />
<Button
android:id="@+id/buttonDevide"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttonblue"
android:text="/"
android:textSize="110sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH3"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_weight=".25"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button4"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="4"
android:textSize="110sp" />
<Button
android:id="@+id/button5"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="5"
android:textSize="110sp" />
<Button
android:id="@+id/button6"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="6"
android:textSize="110sp" />
<Button
android:id="@+id/buttonMult"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttonblue"
android:text="X"
android:textSize="110sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH4"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_weight=".25"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button7"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="7"
android:textSize="110sp" />
<Button
android:id="@+id/button8"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="8"
android:textSize="110sp" />
<Button
android:id="@+id/button9"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="9"
android:textSize="110sp" />
<Button
android:id="@+id/buttonMinus"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttonblue"
android:text="-"
android:textSize="110sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH5"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_weight=".25"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button0"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombutton"
android:text="0"
android:textSize="110sp" />
<Button
android:id="@+id/buttonDot"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttonblue"
android:text="."
android:textSize="110sp" />
<Button
android:id="@+id/buttonEq"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttongreen"
android:text="="
android:textSize="110sp" />
<Button
android:id="@+id/buttonPlus"
style="@style/ButtonText"
android:layout_width="50sp"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:background="@drawable/custombuttonblue"
android:text="+"
android:textSize="110sp" />
</LinearLayout>
</LinearLayout>
我已经读过关于不同屏幕尺寸的问题,但是无论我使用sp还是dp,在800x480屏幕上看起来仍然很糟糕。我应该怎么做才能使字体显示正确,使图片居中且不太紧?首先:对于视图尺寸,不应该使用用户
sp
。用户dp
查看视图的尺寸,而sp
查看文本大小。
第二:如果使用weightsum
和layout\u weight
,则视图宽度不需要尺寸标注,只需给它们0dp值,它们就可以正常绘制
例如,如果使用此配置:
<ImageButton
style="@style/ButtonText"
android:id="@+id/c101_image"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:scaleType="centerInside"
android:background="@drawable/cloud101"
android:layout_weight=".20" />
您的imageButton应在所有屏幕上正确显示。
对所有视图使用相同的技术,它应该可以解决您的问题
注意:文本使用较小的字体:)
祝你好运,
Arkde首先:您不应该为视图维度使用
sp
。用户dp
查看视图的尺寸,而sp
查看文本大小。
第二:如果使用weightsum
和layout\u weight
,则视图宽度不需要尺寸标注,只需给它们0dp值,它们就可以正常绘制
例如,如果使用此配置:
<ImageButton
style="@style/ButtonText"
android:id="@+id/c101_image"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:scaleType="centerInside"
android:background="@drawable/cloud101"
android:layout_weight=".20" />
您的imageButton应在所有屏幕上正确显示。
对所有视图使用相同的技术,它应该可以解决您的问题
注意:文本使用较小的字体:)
祝你好运,
Arkde您的文本大小对于该设备来说太大 在res目录中创建一个布局普通文件夹,并在其中粘贴布局副本。将按钮上的110 SP调低到更小的位置。也许开始尝试使用70sp之类的东西。用不同的尺寸进行测试,直到其中一个看起来不错
此外,如果您想让应用程序支持小屏幕,您还需要为它们制作布局文件的另一份副本。您的文本大小对于该设备来说太大 在res目录中创建一个布局普通文件夹,并在其中粘贴布局副本。将按钮上的110 SP调低到更小的位置。也许开始尝试使用70sp之类的东西。用不同的尺寸进行测试,直到其中一个看起来不错
另外,如果你想让你的应用程序支持小屏幕,你也需要为它们制作另一份布局文件。如果两台设备的密度相同,并且正好适合大屏幕,我可以看到这种情况。你能把页边空白去掉并把文字居中吗?不幸的是,尺寸限定符在android 3.2之前是不可用的,或者它们可能会有所帮助。试一试:我认为它解决了你的问题:[link]我可以看到,如果两台设备的密度相同,并且正好适合较大的一台,就会出现这种情况。你能把页边空白去掉并把文字居中吗?不幸的是,尺寸限定符在android 3.2之前不可用,或者它们可能会有所帮助。试试这个:我认为它解决了您的问题:[链接]我现在只需要找到一种方法,在平板电脑屏幕上使字体变大,在平板电脑屏幕上70 sp又太小了:(我现在只需要找到一种方法使平板电脑屏幕上的字体变大,在平板电脑屏幕上,70 sp又太小了:(