java按显示自动切换文本视图大小
请告诉我textView中的大小有问题
我有。xml代码,其中我使用线性/水平/框架布局,在布局中有一些对象(textview),在textview中有相同的文本
我需要根据手机显示切换文本大小。 但是如果我把130dp放在小显示器上是不好的
我的一点代码
<LinearLayout
安卓:orientation="horizontal"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:baselineAligned="false">
<LinearLayout
安卓:orientation="horizontal"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:layout_weight="2">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="fill_parent"
安卓:textAppearance="?安卓:attr/textAppearanceLarge"
安卓:text="88"
安卓:id="@+id/hlc"
安卓:textSize="130dp"
安卓:textIsSelectable="false"
安卓:gravity="end"
安卓:textStyle="bold" />
<LinearLayout
安卓:orientation="vertical"
安卓:layout_width="0dp"
安卓:layout_height="wrap_content"
安卓:paddingTop="0dp"
安卓:layout_weight="10">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceLarge"
安卓:text="°"
安卓:id="@+id/textView15"
安卓:textSize="@安卓:dimen/notification_large_icon_width"
安卓:textIsSelectable="false"
安卓:textStyle="bold"
安卓:layout_weight="9"
安卓:textAlignment="viewStart" />
<TextView
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceLarge"
安卓:text="8"
安卓:id="@+id/hld"
安卓:textSize= "@安卓:dimen/notification_large_icon_width"
安卓:textStyle="bold"
安卓:textAlignment="viewStart"
安卓:layout_weight="1" />
</LinearLayout>
</LinearLayout>
如果我使用@安卓:dimen/thumbnail\u width,它对我的格式化显示来说太大了
我需要在textview中用文本填充framelayput
我不能把图像放在这里:(
。。。如何使用小值、大值等?请举个例子。示例声明和示例在xml中的使用
谢谢
# 1 楼答案
您可以使用不同的
sp
为不同的大小创建不同的维度文件夹(最好使用sp
而不是dp
作为文本大小)检查此documentation以获得更好的轻描淡写
并检查this