2013-04-19 4 views
6

(내 질문에 대해 죄송합니다.)EditText에서 텍스트를 수직으로 작성하는 방법 (안드로이드)

어떻게하면 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

는 < 상대> 또는 < 있는 LinearLayout>와 FrameLayout이를 교체합니다. 또한 부모 레이아웃의 android : gravity = "center"속성을 설정하십시오.

관련 문제