2013-04-19 17 views
6

(Üzgünüm benim zavallı soru için. Ben hemen güncelleyin) genelNasıl EditText metni yapmak için dikey (Android)

Nasıl XML dosyasında bunu yapabilir? 90" rotasyon yapmak

<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

Bir 'EditText' veya' TextView' ister misiniz? Ayrıca, şu anki kodunuzla çalışmayan nedir? – TronicZomB

+0

neyin doğru değil? tam olarak ne istiyorsun pic ile aynı mı? İmleç nasıl gösterilir? veri nasıl eklenir? – stinepike

+1

"Doğru değil" in ne anlama geldiğini açıklamadığınız sürece, kimse size gerçekten yardımcı olamaz. Ayrıca, 'android: rotasyon' yalnızca API Seviye 11'de veya üstünde çalışacağını unutmayın. – CommonsWare

cevap

2

Birkaç girmek için gidiyoruz: - "= dönüşünü android" Ben kullanılan (kod aşağıdaki kullanmaya çalıştı ama doğru değil. sorunlar bu şekilde yapmaya çalışırsanız en belirgin sorunu yanlış ölçüm olacak Bunun yerine özel bir görünüm oluşturmanız gerekir şey böyle.:..

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(); 
    } 
} 

I have not Bunu gerçekten test ettim, ama böyle başlayacağım.

0

< Bağıl> ya < LinearLayout> ile FrameLayout değiştirin. Ayrıca, ebeveyn düzeninin android: gravity = "center" özelliğini ayarlayın.