2010-05-01 82 views
13

我想在Android中左下對齊我的文本。如何在android中對齊文本

+0

您有什麼看法XML目前? – jball 2010-05-01 17:16:28

+0

你有什麼代碼,你用的是什麼樣的xml看起來像atm? – wheaties 2010-11-21 16:21:35

回答

29

如果要將TextView中的文本與左下角對齊,請使用android:gravity="bottom|left"。如果要將TextView對齊其容器的左下角,請使用android:layout_gravity="bottom|left"

儘管如此,我懷疑你是在誤傳你的真實意圖。你想將某些文字對齊左下角的內容?屏幕?文本的容器?

請嘗試更具體地處理您的問題。

屏幕左下方的:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:gravity="bottom|left" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TextView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="text"/> 
</FrameLayout> 
+0

屏幕左下方 – ryan 2010-05-04 02:16:06

+0

我編輯了答案。 – synic 2010-05-04 05:03:41

+0

我不會爲此使用框架佈局。改爲使用相對佈局。 – Janusz 2010-11-21 16:20:50

1

我會建議Relative layout

您的看法是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <TextView 
     android:id="@+id/label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Text aligned bottom left" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true"/> 

</RelativeLayout>