如何纠正的Android Activity的布局元素堆叠在彼此? [英] How to correct Android Activity's Layout elements stacking over each other?
问题描述
我在我的应用程序的活动布局的问题。搜索结果顶部的元素(文本视图,编辑文本框)来了错杂。
结果有某种元素之间的重叠尽管XML布局的code看起来不错(一个类似设计code是被其他活动使用,是工作的罚款)。搜索结果下面是截图(注意靠近顶端元件重叠):搜索结果
I have a problem in the layout of my app's activity.
The top elements (text-views, edit text boxes) are coming jumbled up.
There is some sort of overlapping between elements though XML Layout's code looks fine (a similarly designed code is in use by another activity and is working fine).
Here is a ScreenShot (notice the overlapping of elements near top):
结果我的XML布局的code:(仅供参考)结果
My XML Layout's code:(for reference)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/my_main_border"
android:fillViewport="true" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:context=".Ques1" >
<TextView
android:id="@+id/textView_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_marginTop="26dp"
android:text="@string/name_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@id/textView_outlet"
android:layout_toRightOf="@id/textView_outlet"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,'1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_outlet"
android:background="@android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="@+id/textView1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view1"
android:text="@string/name_owner"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1_owner"
android:layout_toRightOf="@id/textView1_owner"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.' "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_owner"
android:background="@android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="@+id/textView1_phonenos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view2"
android:text="@string/phone_nos"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_phonenos"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/textView1_phonenos"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="3"
android:textSize="12sp" />
<EditText
android:id="@+id/editText1_phonenos2"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/editText1_phonenos"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="4"
android:textSize="12sp" />
<EditText
android:id="@+id/editText1_phonenos3"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/editText1_phonenos2"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<EditText
android:id="@+id/editText1_phonenos4"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/editText1_phonenos3"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_phonenos4"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view3"
android:text="@string/name_state"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1_state"
android:layout_toRightOf="@id/textView1_state"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.' "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view4"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_state"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view4"
android:text="@string/name_city"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1_city"
android:layout_toRightOf="@id/textView1_city"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view5"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_city"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view5"
android:text="@string/market"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1_market"
android:layout_toRightOf="@id/textView1_market"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,'1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view6"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_market"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_gps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view6"
android:text="@string/gps_coord"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_gps"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignBaseline="@id/textView1_gps"
android:layout_toRightOf="@id/textView1_gps"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view7"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_gps"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_outlet_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view7"
android:text="@string/pic_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/Button01_outletpic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/textView1_outlet_pic"
android:drawableLeft="@drawable/select_pic"
android:text="@string/selectPic_btn"
android:textSize="10sp" />
<View
android:id="@+id/view8"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/Button01_outletpic"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_quad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view8"
android:text="@string/quad_code"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1_quad"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignBaseline="@id/textView1_quad"
android:layout_toRightOf="@id/textView1_quad"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="@+id/view9"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/editText1_quad"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view9"
android:text="@string/own_veh"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1_own_veh"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/radio0_yes"
android:textSize="13sp" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/radio0"
android:text="@string/radio1_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="@+id/view10"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/radioGroup1_own_veh"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_own_sales_team"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view10"
android:text="@string/own_sales_team"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup1_own_salesT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1_own_sales_team"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio011"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/radio011_yes"
android:textSize="13sp" />
<RadioButton
android:id="@+id/radio022"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/radio011"
android:text="@string/radio022_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="@+id/view11"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/radioGroup1_own_salesT"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_own_goods_collect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view11"
android:text="@string/own_goods_collect"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup1_own_goods_coll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1_own_goods_collect"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio033"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/radio033_yes"
android:textSize="13sp" />
<RadioButton
android:id="@+id/radio044"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/radio033"
android:text="@string/radio044_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="@+id/view12"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/radioGroup1_own_goods_coll"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_monthly_vOl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view12"
android:text="@string/monthly_vOl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/cbCat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1_monthly_vOl"
android:layout_marginLeft="50dp"
android:text="@string/cat1"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/cbCat1"
android:layout_marginLeft="55dp"
android:layout_toRightOf="@id/cbCat1"
android:text="@string/cat2"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cbCat1"
android:layout_marginLeft="50dp"
android:text="@string/cat3"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/cbCat3"
android:layout_marginLeft="9dp"
android:layout_toRightOf="@id/cbCat3"
android:text="@string/cat4"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cbCat3"
android:layout_marginLeft="50dp"
android:text="@string/cat5"
android:textSize="13sp" />
<View
android:id="@+id/view13"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/cbCat5"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="@+id/textView1_monthly_vAl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view13"
android:text="@string/monthly_vAl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/cbCat11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1_monthly_vAl"
android:layout_marginLeft="50dp"
android:text="@string/cat11"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/cbCat11"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@id/cbCat11"
android:text="@string/cat22"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cbCat11"
android:layout_marginLeft="50dp"
android:text="@string/cat33"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/cbCat33"
android:layout_marginLeft="9dp"
android:layout_toRightOf="@id/cbCat33"
android:text="@string/cat44"
android:textSize="13sp" />
<CheckBox
android:id="@+id/cbCat55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cbCat33"
android:layout_marginLeft="50dp"
android:text="@string/cat55"
android:textSize="13sp" />
<View
android:id="@+id/view14"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/cbCat55"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<View
android:id="@+id/viewMenuBarP1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@id/view14"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<Button
android:id="@+id/btnNxtPage2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/viewMenuBarP1"
android:layout_centerInParent="true"
android:gravity="center"
android:text="@string/btnNextPage2" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
任何意见是AP preciable ..结果在此先感谢
Any advice is appreciable..
Thanks in advance
推荐答案
使用Android:layout_alignBaseline =@ ID / textView_outlet,而不是机器人:layout_alignBaseline =@ + ID / textView_outlet
Use android:layout_alignBaseline="@id/textView_outlet" and not android:layout_alignBaseline="@+id/textView_outlet"
@ + id是创建一个新的ID,而ID已经被创建时@id被使用。
@+id is to create a new id whereas @id is used when the id has already been created.
请随时提出任何疑问。如果问题仍然存在,
Please feel free to ask any doubts if the problem persists
这篇关于如何纠正的Android Activity的布局元素堆叠在彼此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!