文本裁剪的android textView
我有4个textview,它们的大小取决于指导方针,指导方针的位置是正确的,因为它已经在整个项目中使用。我尝试了许多解决方案,但没有一个能帮助我解决问题。无论屏幕大小、字体大小或文本大小,我的文本总是被裁剪 我寻找了一些选项,可以根据容器的大小自动调整textfield文本的字体大小,但对我来说不起作用 这是我正在寻找的结果 这些文本视图是扩展android.support.v7.widget.AppCompatTextView的自定义文本视图,但到目前为止没有对文本本身进行任何修改 编辑:这是我的自定义类文本裁剪的android textView,android,textview,Android,Textview,我有4个textview,它们的大小取决于指导方针,指导方针的位置是正确的,因为它已经在整个项目中使用。我尝试了许多解决方案,但没有一个能帮助我解决问题。无论屏幕大小、字体大小或文本大小,我的文本总是被裁剪 我寻找了一些选项,可以根据容器的大小自动调整textfield文本的字体大小,但对我来说不起作用 这是我正在寻找的结果 这些文本视图是扩展android.support.v7.widget.AppCompatTextView的自定义文本视图,但到目前为止没有对文本本身进行任何修改 编辑:
public class MyTextView extends android.support.v7.widget.AppCompatTextView {
private Context context = null;
private AttributeSet attrs = null;
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
this.attrs = attrs;
setWillNotDraw(false);
setIncludeFontPadding(false);
}
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh){
super.onSizeChanged(w, h, oldw, oldh);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
}
这是xml
<android.support.constraint.Guideline
android:id="@+id/TopOf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.031200000000000002" />
<android.support.constraint.Guideline
android:id="@+id/StartOf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0" />
<android.support.constraint.Guideline
android:id="@+id/BottomOf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.9062" />
<android.support.constraint.Guideline
android:id="@+id/EndOf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.16477" />
<com.customView.MyTextView
android:id="@+id/MyTextView"
android:fontFamily="roboto"
android:text="Downloads"
android:textColor="#5d5d5d"
android:textSize="8dp"
app:autoSizeTextType="uniform"
android:textStyle="bold"
android:gravity="left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layout_constraintStart_toStartOf="@+id/StartOf"
app:layout_constraintTop_toTopOf="@+id/TopOf"
app:layout_constraintEnd_toEndOf="@+id/EndOf"
app:layout_constraintBottom_toBottomOf="@+id/BottomOf" />
您需要提供textview的
android:layout\u height=“wrap\u content”
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:padding="5dp"
android:text="text" />
分享你的代码,展示你做了什么?添加你的代码和xml部分。