2017-03-21 8 views
0
에서 글꼴의 높이를 변경할 수 나는이 AutoFitTextView 사용하고

: http://www.andreamaglie.com/android-auto-fit-textview/나는 텍스트 뷰

을하며, 잘 작동하고 표시된 모든 텍스트와 크기를 조정할 글꼴의

enter image description here

문제가 내가 원하는입니다 사용 가능한 공간이 있으므로 높이를 늘리십시오. 테두리가 보이면 공간이 있습니다.

자바 코드 :

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 (자세한 설명) :

문제는 내가 크기를 늘릴 경우 텍스트가 모두 표시하지 않기 때문에 글꼴 "높이"없습니다 "크기"를 증가 할 수 있습니다.

충분하지 컨테이너의 "폭", 난 그냥 폭하는 문제 때문에 "폭"을 감소하려는 때문에 AutoFitTextView는 텍스트 "크기"(폭과 높이) 크기를 조정합니다.

+0

이 뷰 또는 텍스트 뷰 뒤에 어떤 레이아웃이 있다는 것입니다 변경? –

+0

@quicklearner 요점을 업데이트했습니다. 부모는 유형의 레이아웃입니다 : PercentRelativeLayout –

+0

textviews 높이를 시도하지 말고 콘텐츠를 감싸 야합니다. –

답변

0

이 두 내 문제를 해결 :

txtV.setScaleY를() - 높이를

txt.setTextScaleX()를