這裏是我的代碼:的Android如何適應TEXTSIZE中的TextView
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_weight="3"
android:weightSum="4">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="P" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:text="Bryant" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="27" />
</LinearLayout>
當outest佈局的高度爲120dp,文字無法顯示完整的單詞(如「Y」只SHWO上部) ,我認爲這是因爲文字太大。
但是,當我設置爲150dp時,文本可以顯示整個單詞。
是否有任何方法來設置文本的文本大小自動適合textview顯示整個單詞。
我不想將textsize硬編碼爲12sp。
而且,我只想在xml中做。
謝謝。
你有沒有想過將你的LinearLayout設置爲'wrap_content'而不是120dp? – Wenhui 2013-02-08 17:33:21
或設置你的文字視圖高度爲'wrap_content' – FoamyGuy 2013-02-08 17:37:28
我只是看不到任何理由爲什麼它不顯示整個文本...你會介意發佈整個xml嗎?因爲儘可能多的我可以看到,你只是比你的文字高度,所以他們應該被看到。 120dp就足夠4個文本的默認文本大小,我假設... – yahya 2013-02-08 18:48:32