java你能告诉我代码中的问题是什么吗
我在相对布局中使用水平滚动视图。但是我没有得到编辑文本和按钮的正确对齐,甚至我也没有得到滚动视图。请告诉我我的代码出了什么问题
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:id="@+id/serviceslayout"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:layout_toRightOf="@id/layout1"
安卓:background="#fff">
<HorizontalScrollView 安卓:layout_width="wrap_content" 安卓:layout_height="wrap_content" 安卓:background="#333333" 安卓:scrollbarFadeDuration="0">
<RelativeLayout
安卓:id="@+id/serviceslayout2"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:layout_toRightOf="@id/layout1"
安卓:background="#fff">
<TextView 安卓:layout_width="wrap_content" 安卓:id="@+id/txtTieover" 安卓:textColor="#000" 安卓:layout_height="65px" 安卓:text="tie-over" 安卓:layout_below="@+id/txtQuantity2" 安卓:layout_alignParentLeft="true" 安卓:layout_marginLeft="21dp" 安卓:layout_marginTop="13dp"></TextView>
<TextView 安卓:layout_width="wrap_content" 安卓:id="@+id/txtQuantity2" 安卓:textColor="#000" 安卓:layout_height="wrap_content" 安卓:text="Quantity" 安卓:layout_alignParentTop="true" 安卓:layout_centerInParent="true" 安卓:layout_toRightOf="@+id/txtTieover" 安卓:layout_marginLeft="155dp" 安卓:layout_marginTop="20dp" 安卓:layout_gravity="center_horizontal"></TextView>
<TextView 安卓:layout_width="wrap_content" 安卓:id="@+id/textView1" 安卓:textColor="#000" 安卓:layout_height="70px" 安卓:text="insert" 安卓:layout_below="@+id/txtTieover" 安卓:layout_alignRight="@+id/txtTieover" 安卓:layout_marginTop="1dp"></TextView>
<TextView 安卓:layout_width="wrap_content" 安卓:id="@+id/textView2" 安卓:textColor="#000" 安卓:layout_height="55px" 安卓:text="direct bury" 安卓:layout_below="@+id/textView1" 安卓:layout_toLeftOf="@+id/txtQuantity2" 安卓:layout_marginTop="1dp"></TextView>
</RelativeLayout>
</HorizontalScrollView>
</RelativeLayout>
# 1 楼答案
首先,您的id为的相对布局:
serviceslayout
已对齐toRightOf
另一个布局(我希望已经声明了,因为上面给出的代码中没有id为layout1
的布局)此外,如果你的
layout1
(如果定义)在布局中的宽度为fill_parent
,那么上面的相关布局都不可见。。。因此,确保你的布局不会占据整个屏幕希望这有帮助
# 2 楼答案
我认为在水平滚动视图中使用
android:layout_width="wrap_content" android:layout_height="wrap_content"
很奇怪。 最好在水平滚动视图中指定精确值或“填充父对象”# 3 楼答案
我想向您推荐这个关于视图层次结构和ui分析的非常有用的教程:http://mobile.tutsplus.com/tutorials/android/android-tools-leveraging-the-hierarchy-viewer-for-ui-profiling/