2012-03-07 104 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);