2017-03-21 75 views
0

我用這AutoFitTextView:http://www.andreamaglie.com/android-auto-fit-textview/我可以更改字體的高度在TextView的

,它的做工精細,並顯示所有文字和大小的字體,

enter image description here

問題是我想增加高度,因爲有可用空間,因爲你看到的邊界有空間。

Java代碼:

PercentRelativeLayout layout = (PercentRelativeLayout) findViewById(R.id.temp_layout); 


    AutoTxtV txtV = new AutoTxtV(this); 
    txtV.setMaxLines(1); 
    txtV.setMinTextSize(1); 
    txtV.setTextSize(TypedValue.COMPLEX_UNIT_SP,16); 
    txtV.setGravity(Gravity.CENTER_VERTICAL); 
    txtV.setTextColor(getResources().getColor(R.color.card_name_white)); 


    txtV.setText("HELLO WORLD HELLO WORLD ABCDEFGHIJKLM"); 


    layout.addView(txtV); 

XML:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.percent.PercentRelativeLayout   xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/parent_layout" 
android:layout_width="279dp" 
android:layout_height="405dp" 
android:background="@drawable/background"> 



<android.support.percent.PercentRelativeLayout 
    android:id="@+id/temp_layout" 
    android:orientation="horizontal" 
    app:layout_heightPercent="7.5%" 
    app:layout_marginLeftPercent="7.3%" 
    app:layout_marginTopPercent="4%" 
    app:layout_widthPercent="74.5%"> 
</android.support.percent.PercentRelativeLayout> 
</android.support.percent.PercentRelativeLayout> 

有什麼辦法來增加高度,也許改變字體類型?

UPDATE(更多解釋):

的問題是我想要的字體「高度」,以增加不「大小」,因爲如果我增加大小的文本將不會顯示全部。因爲容器的「寬度」不夠,我只想減小「寬度」,因爲寬度只是問題所在。

+0

是一個視圖或後面的TextView任何佈局? –

+0

@quicklearner我更新了要點,父類是佈局類型:PercentRelativeLayout –

+0

您應該使其包裝內容而不是嘗試textviews高度 –

回答

0

這兩個解決我的問題:

txtV.setScaleY() - 改變高度

txt.setTextScaleX()

相關問題