2013-04-19 16 views
6

(Przepraszam za moje słabe pytanie, zaktualizowałem je teraz)Jak zrobić tekst w EditText pionowo (Android)

Jak mogę zrobić to w pliku XML? Próbuję użyć następującego kodu, ale nie jest poprawna (użyłem "android: obrót =" - 90" , aby zrobić obrót

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<FrameLayout 
    android:layout_width="141dp" 
    android:layout_height="200dp" 
    android:layout_weight="0.41" 
    android:orientation="vertical" > 

    <EditText 
     android:id="@+id/sidebar_title" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/shape_card_sidebar" 
     android:inputType="text" 
     android:rotation="-90" 
     android:text="I want to be like this" > 
    </EditText> 
</FrameLayout> 

enter image description here

+1

Chcesz "EditText" lub "TextView"? Co też nie działa z twoim aktualnym kodem? – TronicZomB

+0

co nie jest poprawne? czego dokładnie chcesz? tak samo jak zdjęcie? jak będzie pokazywany kursor? jak wstawić dane? – stinepike

+1

Jeśli nie wyjaśnisz, co oznacza "nie jest poprawne", nikt nie może ci naprawdę pomóc. Zwróć też uwagę, że 'Android: rotacja' działa tylko na poziomie API 11 lub wyższym. – CommonsWare

Odpowiedz

2

Będziesz napotkasz kilka. problemy, jeśli starają się zrobić to w ten sposób najbardziej oczywistym problemem będzie błędny pomiar Zamiast tego należy utworzyć widok niestandardowy coś takiego:...

public class RotatedTextVew extends TextView { 
    public RotatedTextView(Context context) { 
     super(context); 
    } 

    public RotatedTextView(Context context, AttributeSet attrs) { 
     super(context, attrs) 
    } 

    public RotatedTextView(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
     // Switch dimensions 
     super.onMeasure(heightMeasureSpec, widthMeasureSpec); 
    } 

    @Override 
    protected void onDraw(Canvas canvas) { 
     canvas.save(); 
     canvas.rotate(90); 
     super.onDraw(canvas); 
     canvas.restore(); 
    } 
} 

nie mam faktycznie to testowałem, ale tak właśnie bym zaczął.

0

Wymień FrameLayout z < względna> lub < LinearLayout>. Ustaw także właściwość android: gravity = "center" układu nadrzędnego.

Powiązane problemy