2013-04-19 9 views
6

(私の貧しい質問に申し訳ありません)私は今更新しています。EditTextでテキストを縦に作る方法(Android)

私はXMLファイルで作ることができますか? 90" は回転を行うには

<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

'EditText'や' TextView'が必要ですか?また、あなたの現在のコードで動作しないものはありますか? – TronicZomB

+0

何が正しくありませんか?あなたは何をしたいですか?写真と同じ?どのようにカーソルが表示されますか?どのようにデータを挿入する? – stinepike

+1

「正しい」とは何かを説明していない限り、誰もあなたを本当に助けることができません。また、 'android:rotation'はAPIレベル11以上でのみ機能します。 – CommonsWare

答えて

2

あなたは、いくつかの中に実行するつもりだ - :「=回転アンドロイドを」私は私が使用した(次のコードを使用しようとしましたが、正しくありません。問題あなたはそのように行うことをしようとした場合、最も明白な問題が間違って測定されます代わりにカスタムビューを作成する必要があり、このような何か:。。。

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

私は持っていません実際にこれをテストしましたが、これが私が始める方法です。

0

< 相対であなたのでframeLayoutを交換>または< のLinearLayout>。また、親レイアウトのandroid:gravity = "center"プロパティを設定します。

関連する問題