由于我有一个Nexus 5,我看到有关文字大小的奇怪东西。文字大小不同的Android手机
一个例子:我正在创建listview项目。我在22sp放了一个更大的文本,17sp放一个较小的文本。
在我的HTC One X,它看起来像这样:
所以我觉得 “OK,这很好!”
然后,我在我的Nexus 5的运行它:
我不明白为什么会这样? “sp”部分不应该确保它看起来不错 使用默认值?我不是在谈论增加设置中字体大小的用户,我已经将所有内容都设置为默认值。如果我愿意(不要打我)在这里使用DP来禁用字体大小的文本变化,它会给出相同的结果(未测试,但我相当肯定这是从其他测试的情况下, )。
这里有什么问题吗?它是较新的Android版本,还是1080p屏幕与720p?
我应该使用“值”文件夹为不同的DP值使用不同的值吗?
这里是德布局:
<?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="80dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/background"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="2">
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:adjustViewBounds="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_toLeftOf="@id/arrow"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fontFamily="sans-serif-condensed"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textSize="17sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
添加了布局。我预计'保证金'是原因 – Boy
我实际上试图避免相对布局,因为我认为这会比'使用线性布局'花费更多' – Boy
如果您不使用重量,LinearLayouts速度很快,否则会变得非常昂贵。 –