简体   繁体   English

不同密度设备的字体大小

[英]Font size for different density devices

When I tested the font size with different density settings using the Eclipse Emulator, I get different size fonts even though I am using "dp" to specific the size. 当我使用Eclipse Emulator测试不同密度设置的字体大小时,即使我使用“dp”来指定大小,我也会得到不同大小的字体。 I would have thought the size may decrease with higher density, but I found the higher the density, the bigger the font is. 我原本认为尺寸​​可能随着密度的增加而减小,但我发现密度越高,字体越大。 I tried using "in" and "mm" and the same behavior occurs, in that the higher density, the bigger the fonts. 我尝试使用“in”和“mm”并且出现相同的行为,因为密度越高,字体越大。 This is based on android:minSdkVersion="10". 这是基于android:minSdkVersion =“10”。

Is there any way I can set the font sizes to scale to the same size for the different density? 有什么办法可以设置字体大小以扩大到不同密度的相同大小?

Here is the xml file: 这是xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:layout_gravity="center"
    android:textColor="@color/orange"
    android:textStyle="bold"
    android:text="THIS IS A TEST"
    android:background="@color/white"/>
</LinearLayout>

Unfortunately I cannot post the images of the font size for the three Emulator settings due to lack of reputation. 遗憾的是,由于缺乏声誉,我无法发布三个模拟器设置的字体大小的图像。

Thank you. 谢谢。

Use sp instead of dp 使用sp而不是dp

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:layout_gravity="center"
    android:textColor="@color/orange"
    android:textStyle="bold"
    android:text="THIS IS A TEST"
    android:background="@color/white"/>

</LinearLayout>

我有同样的问题...并没有找到任何东西,但没有找到任何东西,但制作文件夹:布局 - 小...大,xlarge,文件夹与高,中,小密度的可绘制图像与根据它的图像resolutios ..所以,一切都适用于不同屏幕的不同机器人......对于每个显示器尺寸,都有不同含义的dp布局...((

I guess one way is this: 我想有一种方法是这样的:

When you make new layout file there is next button in eclipse. 当您创建新的布局文件时,eclipse中有下一个按钮。 Press that and there is a list where to pick layout's density. 按下那个,有一个列表可以选择布局的密度。 You can pick x-high density, high density, medium density etc.. When you press finish it makes layout folder like "layout-hdpi" (depends what density you pick). 您可以选择x高密度,高密度,中密度等。当您按完成时,它会使布局文件夹像“layout-hdpi”(取决于您选择的密度)。 And then make text fit good with that density. 然后使文本适合该密度。

Hope that helps. 希望有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不同设备上的字体大小 - Font size on different devices 具有不同图像和字体大小的不同设备 - different devices with different image and font size IONIC字体大小在不同设备中看起来不同 - IONIC font size looks different in different devices 了解不同尺寸和像素密度设备上的android ImageView - understanding android ImageView on different size and pixel density devices 以相同的密度和屏幕尺寸类别唯一标识设备,但以英寸为单位的屏幕尺寸不同 - Identify devices uniquely with same density and screen size category but different screen size in inches 为什么在具有相同屏幕尺寸和密度的2个不同设备上,UI呈现的方式不同? - Why does UI render differently for 2 different devices with same screen size and density? 为什么具有相同物理尺寸和分辨率的设备可能具有不同的密度? - Why devices that have same physical size and resolution may have different density? 使TextView的大小在设备和密度上相等 - Make the size of a TextView equal across devices and density 随机设备上的字体不同 - Font is different on random devices 处理Android Nougat上的密度/字体大小更改 - Handling density / font size change on Android Nougat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM