【发布时间】:2015-05-16 13:49:36
【问题描述】:
我找到了一个解决方案,可以在 Auto Scale TextView Text to Fit within Bounds 的 TextView 中放置文本。 但是,我的解决方案似乎不起作用。
这是我的 xml:
<parkpurdue.parkpurdue.AutoResizeTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Park @ Purdue"
android:layout_weight="1.6"
android:background="#3366FF"
android:id="@+id/parkAtPurdue"
android:singleLine="true"
android:gravity="center"
android:textColor="#FFFFFF"
android:maxLines="1"/>
这是我的java代码:
TextView topText = (TextView) findViewById(R.id.parkAtPurdue);
topText.setText("Park at Purdue");
我也试过把java代码改成这样:
AutoResizeTextView topText = new AutoResizeTextView(getApplicationContext());
topText = (AutoResizeTextView) findViewById(R.id.parkAtPurdue);
topText.setText("Park at Purdue");
我也尝试调用 topText.resize() 函数。没有发现明显的结果。我究竟做错了什么?我需要改变什么?
【问题讨论】: