2010-05-01 59 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>