2017-02-06 4 views
0

ich eine benutzerdefinierte Textview erstellt, um eine neue Schriftart hinzuzufügen:Individuelle Textview schneidet mit wrap_content

public class CustomTextView extends TextView{ 

    public CustomTextView(Context context, AttributeSet attrs, int defStyle){ 
     super(context, attrs, defStyle); 
     setTypeface(SplashActivity.SECRET_CODE_TYPEFACE, Typeface.NORMAL); 
    } 

    public CustomTextView(Context context, AttributeSet attrs){ 
     super(context, attrs); 
     setTypeface(SplashActivity.SECRET_CODE_TYPEFACE, Typeface.NORMAL); 
    } 

    public CustomTextView(Context context){ 
     super(context); 
     setTypeface(SplashActivity.SECRET_CODE_TYPEFACE, Typeface.NORMAL); 
    } 
} 

Nun, wenn ich diese Textview verwenden, wird der Text abgeschnitten: Result

und hier ist meine XML:

<com.whereisthemonkey.sqlsheetmanager.Graphics.CustomTextView 
     android:layout_width="match_parent" 
     android:text="@string/title" 
     android:textSize="56sp" 
     android:layout_height="wrap_content" 
     android:gravity="center" /> 

Antwort

2
android:padding="10dp" 

hinzufügen Polsterung in Ihren Text-Ansicht, wie sho wn unten:

<com.whereisthemonkey.sqlsheetmanager.Graphics.CustomTextView 
     android:layout_width="match_parent" 
     android:text="@string/title" 
     android:textSize="56sp" 
     android:padding="10dp" 
     android:layout_height="wrap_content" 
     android:gravity="center" /> 
+1

Danke, es funktioniert noch besser bei der Verwendung von padding-bottom und padding-top –

Verwandte Themen