2017-02-03 1 views
1

Gibt es eine Möglichkeit, die Android-Edittext-Eingabeausrichtung zu ändern? Welche nach unten und rechts oben ist, genau wie die Bilder unten, nach links:Android-Eingabetext-Eingabeausrichtung

i.stack.imgur.com/6T6ht.jpg

Der Stil ist ähnlich wie Japanisch und Chinesisch Brief

https://i.stack.imgur.com/S4u9v.jpg

Danke!


aktualisieren

Sorry für meine unklar Ausdruck, obwohl die Eingangs Ausrichtung korrekt ist, wird die Textrichtung gedreht, was unerwünscht ist. Zum besseren Ausdruck habe ich das Bild unten aktualisiert: https://i.stack.imgur.com/hz6RB.jpg

Vielen Dank !!!!

+0

ist dadurch gelöst, dass oder?? –

Antwort

0

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" /> 
0

Fügen Sie diese auf Ihre editText für Recht

android:textDirection="rtl" 
0

Sie fügen Attribut Rotation in EditText

auf diese Weise
<EditText 
     android:layout_width="match_parent" 
     android:rotation="270" 
     android:layout_height="wrap_content" /> 
0

Versuchen kann nach links, dann andere edittexts erstellen. es funktionierte für mich

<EditText 
     android:layout_width="match_parent" 
     android:rotation="270" 
     android:textDirection="rtl" 
     android:layout_height="wrap_content" />