您好,我创建了自定义textview,我们为其设置了字体 这是我的自定义textview类
public class mTextView extends TextView {
private int CircleColor=0;
// Default constructor when inflating from XML file
public mTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
init(attrs);
}
private void init(AttributeSet attrs) {
//setIncludeFontPadding(false);
if(attrs!=null){
TypedArray a=getContext().obtainStyledAttributes(attrs, R.styleable.mTextView);
String font=a.getString(R.styleable.mTextView_mt_font);
if(font!=null) {
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), font);
setTypeface(typeface);
}
}
}
// Default constructor override
public mTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs);
init(attrs);
setGravity(getGravity() | Gravity.CENTER_VERTICAL); //make sure that the gravity is set to the top
}
}
它工作正常但是当我将drawable设置在textview右侧时,我的textview不显示我的drawable
<tools.mTextView
android:textColor="@color/md_white_1000"
app:mt_font="fonts/irterafik.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="20dp"
android:drawableRight="@drawable/registerdata"
android:gravity="right"
android:text="registerdata"
android:textAppearance="?android:attr/textAppearanceMedium" />
所以有人可以帮忙解决这个问题吗?
答案 0 :(得分:0)
似乎是因为你将重力设置为正确。尝试删除它并查看问题是否已解决