【发布时间】:2017-03-23 18:16:34
【问题描述】:
我正在尝试获取 textview 中文本的大小,以便稍后在代码中使用它。
我已经声明了一个浮点数和我的文本视图
private float mStartTextSize;
private TextView mWordTextView;
然后在我的 onCreate 我有
mWordTextView = (TextView) findViewById(R.id.factTextView);
mStartTextSize = mWordTextView.getTextSize();
但是当我调试和使用我的手机时,即使我在 xml 中将它设置为 30sp,它也会得到 105 的值。
<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"/>
【问题讨论】:
-
谢谢!我很感激。
标签: android resize textview text-size