2013-07-19 2 views
1

왼쪽 텍스트 방향으로 오른쪽을 수행하려하지만 예기치 않은 결과가 나타납니다 (html CSS를 할 때와는 다릅니다). 다음은 해당 텍스트 뷰에 대한 코드입니다.변경 사항에 응답하는 안드로이드 텍스트 뷰 텍스트 방향

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="96dp" 
    android:gravity="right" 
    android:text="@string/welcomeMsg" 
    android:textAlignment="center" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:textColor="@color/white" 
    android:textDirection="rtl" 
    android:textSize="@dimen/welcomeMsgSize" /> 

나는 모든 작업을 수행했다고 생각합니다. 어쩌면 내가 뭔가를 잊었거나 그것을 모른다. 나는 안드로이드에 꽤 새로운 사람이다. 그림은 위의 결과를 보여줍니다. 여기 문제는 textview 내부의 텍스트 앞의 공백이며 텍스트도 게시됩니다. 사전에 당신의 도움 :)

enter image description here

답변

0

안드로이드에 대한 감사합니다 : TEXTSIZE는 = "@ DIMEN/welcomeMsgSize는".. 당신이 거기에 해당 파일에 지정된 크기를 줄일 범인이있다 .. !!

+0

크지 않은 26dp입니다. 사실 나중에 더 커질 필요가 있습니다. –

+0

속성에 패딩 변수가 설정되어 있는지 확인 했습니까? –

+0

위 XML에서 볼 수 있듯이 아무 것도 설정되어 있지 않습니다. –

2

필요에 따라 Textview gravity를 "Center"에서 "Right"또는 "Left"로 변경해야합니다. 중력은 텍스트에 중력을 설정하여 변경합니다. 또한 텍스트 정렬을 중앙에서 오른쪽 또는 왼쪽으로 변경합니다.

+0

docs.http : //developer.android.com/reference/android/view/View.html#attr_android에서 볼 수있는 것이 맞거나 왼쪽에 없습니다. : textAlignment –

+0

TextView에이 속성을 넣으면 모든 것이 잘 동작하여 자동으로 텍스트를 감지하고 그에 따라 변경됩니다. android : textDirection = "anyRtl" –

관련 문제