Android 为什么getTextSize()会随方向变化?
我有一个带有几个文本视图的小Android活动。当我在横向和纵向之间旋转时,字体大小会发生显著变化 一个视图的XML如下所示:Android 为什么getTextSize()会随方向变化?,android,fonts,orientation,scale,Android,Fonts,Orientation,Scale,我有一个带有几个文本视图的小Android活动。当我在横向和纵向之间旋转时,字体大小会发生显著变化 一个视图的XML如下所示: <TextView android:id="@+id/question" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_
<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginTop="@dimen/small_margin"
android:text="@+string/question"
android:textSize="@dimen/medium_text_size" />
当我旋转到纵向模式时,记录的值为72。转到横向,记录了150。正如您所料,文本看起来大约是原来的两倍大。我知道getTextSize返回值与dimens.xml中的值不一样,因为单位不同,但我不明白为什么方向会有不同
对于字体大小,我想做一些事情,但我想先了解一下。宽度或高度是否有不同的尺寸,例如w720dp?否,我唯一的dimens.xml版本是value、values normal、values large和values xlarge。这些值分别是50sp、50sp、70sp和100sp,我假设它们是默认值,因为我没有将它们放在那里。
<dimen name="medium_text_size">50sp</dimen>
questionText = (TextView) findViewById(R.id.question);
Log.d(TAG, "Raw incoming size: " + questionText.getTextSize());