如何在Android中以不同分辨率设置相同的文本?

use*_*954 0 android android-layout

我想在不同的分辨率中设置相同大小的文本.如何做到这一点.我也尝试创建两个新的文件夹,如layout-small,layout-large,layout-xlarge,layout-normal.但仍然没有管理它.请有人帮忙我的问题.谢谢.

Nir*_*ava 5

在你的xml中使用类似的东西来设置文本的大小.它将独立于分辨率.

 <TextView android:id="@+id/name_text"
        android:layout_height="wrap_content"
        android:layout_width="match_parent" 
        android:textSize="10dp"
        />
Run Code Online (Sandbox Code Playgroud)

或者你可以在java代码中执行此操作

    TextView text1 = (TextView) findViewById(R.id.txt);
    text1.setTextSize(10);
Run Code Online (Sandbox Code Playgroud)