2012-03-07 58 views
2

原谅我的下一张图片的右侧和底部,着急:)完成:文本对齐到另一个文本

enter image description here

请任何人可以告诉我怎么可以使用Android的布局和TextViews得到的东西与我画画相似。 带有一个TEXT的盒子是一个字符串,并且带有TEXT TEXT TEXT的盒子是一个字符串。

谢谢。

+1

使用RelativeLayout。 – 2012-03-07 14:44:27

+0

怎么样?我正在使用RelativeLayout。 – 2012-03-07 14:46:59

回答

0

在RelativeLayout的,每个TextView的标签中使用这些属性按您的要求

android:layout_below="Id of the TextView" 
android:layout_above="Id of the TextView" 
android:layout_toLeftOf="Id of the TextView" 
android:layout_toRightOf="Id of the TextView" 
+0

试过所有类型的组合,但我无法得到图像的结果。 – 2012-03-07 15:55:24

0

这样的事情应该做的伎俩。键是layout_belowlayout_toRightOf

<RelativeLayout 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <TextView android:id="@+id/LeftTextView" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:paddingRight="10dp" android:paddingBottom="10dp" 
     android:text="HI"> 
    <TextView android:id="@+id/WholeTextView" 
     android:layout_height="fill_parent" android:layout_width="fill_parent" 
     android:layout_below="@id/LeftTextView" 
     android:layout_toRightOf="@id/LeftTextView"> 
</RelativeLayout> 
+0

不幸的是,它不起作用。 – 2012-03-07 15:34:55

0

出于某种原因,这就是即使它的工作原理个不错的办法。我会建议使用不同的textview的底部行。它可以在相对布局中使用某种组合,但它在每个屏幕/分辨率中可能都不一样。

1

我不想为这种情况使用2个TextView实例。解决方法可能是仅使用一个TextView并以编程方式执行文本格式。

0

您是否尝试过使用compound drawables

textview2.setCompoundDrawables(textview1,null,null,null);