2013-05-21 23 views
1

我想要将两个不同的的基线对齐放置在两个不同的RelativeLayouts中。以下是我使用的代码:在两种不同的布局中对齐文本视图的基线

 <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="right"> 

      <TextView 
       android:id="@+id/tv_city_a" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="City"/> 

     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/tv_city_b" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@id/tv_city" 
       android:background="@drawable/txt_field_white"/> 

     </RelativeLayout> 

我要对齐的tv_city_a基线与tv_city_b但上面的代码是行不通的。

注:由于设计要求,我需要把TextView的两个不同的RelativeLayout的。我不能把它们放在一个。

编辑以下是我得到的输出: enter image description here

+0

能您发布您的输出或您的完整布局 –

+0

删除paddingTop。 – Anukool

+0

你可以把两个相对布局放在一些线性布局 –

回答

0

不能与父母不同的看法链接基线。你唯一的选择就是加入他们在1 RelativeLayout或使它们通过提供正确的填充,保证金,父母对准等等,等等

编辑对齐:错误的输出,因为正在添加你的第二RelativeLayout的有android:paddingTop="5dp"

+0

所以它不可能实现我想要的。还有其他方法吗? –

+0

@VinodMaurya你可以尝试测量TextView A的位置,然后相应地放置TextView B ... – Warpzit

相关问题