2011-09-09 84 views
-1

我在相对布局中使用了水平滚动视图,但没有得到edittext和按钮的正确对齐,甚至没有获得滚动视图。请告诉我什么是错误的在我的代码中。你能告诉我在我的代码中有什么问题

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/serviceslayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_toRightOf="@id/layout1" 
    android:background="#fff"> 

    <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#333333" android:scrollbarFadeDuration="0"> 

    <RelativeLayout 
     android:id="@+id/serviceslayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_toRightOf="@id/layout1" 
     android:background="#fff"> 

     <TextView android:layout_width="wrap_content" android:id="@+id/txtTieover" android:textColor="#000" android:layout_height="65px" android:text="tie-over" android:layout_below="@+id/txtQuantity2" android:layout_alignParentLeft="true" android:layout_marginLeft="21dp" android:layout_marginTop="13dp"></TextView> 

     <TextView android:layout_width="wrap_content" android:id="@+id/txtQuantity2" android:textColor="#000" android:layout_height="wrap_content" android:text="Quantity" android:layout_alignParentTop="true" android:layout_centerInParent="true"  android:layout_toRightOf="@+id/txtTieover" android:layout_marginLeft="155dp" android:layout_marginTop="20dp" android:layout_gravity="center_horizontal"></TextView> 

     <TextView android:layout_width="wrap_content" android:id="@+id/textView1" android:textColor="#000" android:layout_height="70px" android:text="insert" android:layout_below="@+id/txtTieover" android:layout_alignRight="@+id/txtTieover" android:layout_marginTop="1dp"></TextView> 

     <TextView android:layout_width="wrap_content" android:id="@+id/textView2" android:textColor="#000" android:layout_height="55px" android:text="direct bury" android:layout_below="@+id/textView1" android:layout_toLeftOf="@+id/txtQuantity2" android:layout_marginTop="1dp"></TextView> 

    </RelativeLayout> 
</HorizontalScrollView> 
</RelativeLayout> 
+0

请更改问题以反映实际问题(例如布局问题),并发布屏幕截图或布局当前正在如何工作的其他指示符,而不是您期望的。 – jefflunt

回答

1

我认为在水平滚动视图中使用android:layout_width="wrap_content" android:layout_height="wrap_content"是很奇怪的。 你最好指定精确值或“fill_parent”水平滚动视图。

1

首先,你的亲戚布局ID:serviceslayout作为被一致toRightOf另一个布局(其IM希望已经宣布因为有在你的代码中没有编号为layout1的布局)。
此外,如果您的layout1(如果已定义)的layout_width的值为fill_parent,则上述相关布局都不会显示...所以请确保您的layout1不会填满整个屏幕。
希望这会有所帮助。

相关问题