Android 不同显示器上的文本视图

Android 不同显示器上的文本视图,android,Android,请帮助理解。 我需要在一个特定的盒子里出现。 我是这样做的: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" andro


请帮助理解。 我需要在一个特定的盒子里出现。 我是这样做的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fon"
    tools:context=".MainActivity" >

....

<TextView
        android:id="@+id/textView3"
        android:layout_width="200dp"
        android:layout_height="210dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:includeFontPadding="false"
        android:lineSpacingMultiplier="0.8"
        android:textAlignment="center"
        android:textColor="@color/black"
        android:textSize="20sp" />

....
 </RelativeLayout>

....
....
四英寸屏幕上的一切都很好,但若采用大对角线,那个就糟糕了
随着屏幕的增大,文本视图的大小不会改变。
我使用“dp”和“sp”,而不是静态的“px”,但不工作。。。 为什么会这样

截图:


文本视图大小是静态的,因为您已为其定义了固定大小。请使用换行内容

  android:layout_width="wrap_content"
   android:layout_height="wrap_content"

您应该将TextView android:layout_宽度和android:layout_高度调整为

android:layout_width="wrap_content"
android:layout_height="wrap_content"
如果希望TextView在白色背景中居中,则应添加另一个属性

android:layout_centerInParent="true"

您可以为不同的屏幕大小和密度创建不同的资源目录,然后在每个目录中创建
dimens.xml
,提供用于特定屏幕大小的文本大小,例如:

res/values-sw420dp/dimens.xml


这是文本大小的解决方案,但宽度和高度也可以这样做。

更多资源:


尝试使用dip(显示独立像素)。如果使用“换行内容”,文本将全部出现在屏幕上,并且必须是在特定的正方形中。看起来您的帖子在特定时间获得了更多的连续向上投票。如果使用“换行内容”,文本将全部出现在屏幕上,它必须在某个广场上
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="font_size">26sp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="font_size">30sp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="font_size">36sp</dimen>
</resources>
android:textSize="@dimen/font_size"