Sie können mit benutzerdefinierten VerticalEditText Versuchen Sie, wie unten
Klasse - VerticalEditText.java
package com.cj.myapplication.croper;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.EditText;
/**
* Created by CHETAN JOSHI on 2/3/2017.
*/
public class VerticalEditText extends EditText {
private Rect bounds = new Rect();
private TextPaint textPaint;
private int color;
public VerticalEditText(Context context) {
super(context);
}
public VerticalEditText(Context context, AttributeSet attrs) {
super(context, attrs);
color = getCurrentTextColor();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
textPaint = getPaint();
textPaint.getTextBounds(getText().toString(), 0, getText().length(), bounds);
setMeasuredDimension((int) (bounds.height() + textPaint.descent()), bounds.width());
}
@Override
protected void onDraw(Canvas canvas) {
textPaint.setColor(color);
canvas.rotate(-90, bounds.width(), 0);
canvas.drawText(getText().toString(), 0, -bounds.width() + bounds.height(), textPaint);
}
}
wie unten in XML hinzufügen:
<com.cj.myapplication.croper.VerticalEditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/holo_red_dark"
android:gravity="center"
android:text="bbfrbgbrfgbirfbgubui"
android:textColor="@color/colorPrimary" />
ist dadurch gelöst, dass oder?? –