Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将xml视图彼此对齐并从同一点开始_Android_Xml - Fatal编程技术网

Android 如何将xml视图彼此对齐并从同一点开始

Android 如何将xml视图彼此对齐并从同一点开始,android,xml,Android,Xml,我在layout.xml中设计了红色标签,使其如图所示相互放置,但从同一起点“黑线”开始,我尝试了这一部分,但无法实现 请参阅下面的xml文件。 我试图将标有红色的每个视图的layout\u width更改为match\u parent,但这会使标签从最左边开始,就好像它们是左对齐的一样。请让我知道我应该添加什么到布局中,以使视图从黑线开始 xml: 输出图像: 有很多种方法可以解决这个问题 1,如果黑线是图像视图,则只需设置它的报告RealtiveLayout02布局。并将标签设置为ali

我在
layout.xml
中设计了红色标签,使其如图所示相互放置,但从同一起点“黑线”开始,我尝试了这一部分,但无法实现

请参阅下面的xml文件。 我试图将标有红色的每个视图的
layout\u width
更改为
match\u parent
,但这会使标签从最左边开始,就好像它们是左对齐的一样。请让我知道我应该添加什么到布局中,以使视图从黑线开始

xml:


输出图像:
有很多种方法可以解决这个问题

1,如果黑线是
图像视图
,则只需设置它的
报告RealtiveLayout02
布局。并将标签设置为
alignedToParentLeft

2、黑线更可能不存在。因此只需将标签设置为
alignedToParentLeft
,并将其
margin\u left
设置为合适的数字即可


我想知道你是如何让“ImgTile”和“ImgPath”保持一个正确的位置的,就像他们一样

您在每个
RelaviteLayout
中编写了
android:layout_gravity=“center | center_vertical”

我建议您删除这行代码。此代码将自动
居中
其子项<代码>垂直居中
正常。但
Center
并不可取。相反,您也可以使用以下代码

android:layout_gravity="left|center_vertical"
使用下面的代码

尝试使用表布局。我很快就会尝试,并向informglad提供帮助。。。向上投票将是另一种乐趣:)
android:layout_gravity="left|center_vertical"
use below Code


   <RelativeLayout 
        android:id="@+id/reportRealtiveLayout02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
           <TextView 
                android:id="@+id/reportLocNameLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Name: "
                android:layout_alignParentLeft="true"
                android:textColor="@android:color/holo_red_dark"/>
            <TextView 
                android:id="@+id/reportLocNameValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/reportLocNameLabel"/>

            <TextView 
                android:id="@+id/reportLocLatLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Lat: "
                android:textColor="@android:color/holo_red_dark"
                android:layout_alignParentLeft="true"
                android.layout_below="@+id/reportLocNameLabel"/>
            <TextView 
                android:id="@+id/reportLocLatValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android.layout_below="@+id/reportLocNameValue"
                android:layout_toRightOf="@+id/reportLocLatLabel"/>

            <TextView 
                android:id="@+id/reportLocLngLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Lng: "
                android:layout_alignParentLeft="true"
                android.layout_below="@+id/reportLocNameLabel"
                android:textColor="@android:color/holo_red_dark"/>
            <TextView 
                android:id="@+id/reportLocLngValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android.layout_below="@+id/reportLocLatValue"
                android:layout_toRightOf="@+id/reportLocLngLabel"/>

            <TextView 
                android:id="@+id/reportTimeLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Time: "
                android:layout_alignParentLeft="true"
                android.layout_below="@+id/reportLocLngLabel"
                android:textColor="@android:color/holo_red_dark"/>
            <TextView 
                android:id="@+id/reportTimeValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android.layout_below="@+id/reportLocLngValue"
                android:layout_toRightOf="@+id/reportTimeLabel"/>
    </RelativeLayout>