0
我想获取文本的大小,在稍后的代码中使用它。Android - 使textview自动调整大小的文本,以适应布局
我宣布一个浮子和我的TextView作为这样
private float mStartTextSize;
private TextView mWordTextView;
,然后在我的onCreate我有
mWordTextView = (TextView) findViewById(R.id.factTextView);
mStartTextSize = mWordTextView.getTextSize();
但正如我调试和使用我的手机,它得到的105值即使我把它设置为xsp中的30sp。
<TextView
android:layout_width="match_parent"
android:layout_height="55dp"
android:text="@string/choose_teams"
android:singleLine="false"
android:id="@+id/wordTextView"
android:textSize="30sp"
android:textColor="@android:color/white"
android:textStyle="bold|italic"
android:layout_below="@+id/titleTextView"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:gravity="top|center"/>
谢谢!我很感激。 –