使用其他布局的视图对象定位一个布局的视图对象

时间:2017-11-14 14:29:32

标签: android xml android-layout

image here for better understanding我有3个线性布局,每个布局有三个对象。我想要的是相对于第一个线性布局的文本视图定位(假设)第三个线性布局的图像视图。 如果这个问题看起来很愚蠢,我对Android编程感到抱歉。

这里的XML代码:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/uppermainLinear">

            <TextView
                android:id="@+id/orderlistordernumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Order"
                android:textColor="@android:color/black"
                android:fontFamily="Ubuntu-B"
                android:layout_marginLeft="@dimen/size_device_32"
                android:layout_marginTop="@dimen/_10sdp"
                android:layout_marginBottom="@dimen/_10sdp"
                android:textSize="@dimen/_12sdp"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:weightSum="5"
            android:paddingBottom="@dimen/_10sdp"
            android:orientation="horizontal"
            android:id="@+id/mainLinear"
            android:layout_below="@+id/uppermainLinear">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:gravity="right"
                android:layout_marginRight="@dimen/_5sdp"
                android:layout_weight="0.4">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/size_device_70"
                    android:adjustViewBounds="true"
                    android:layout_marginTop="@dimen/_2sdp"
                    android:id="@+id/ordelistbookingleftImage"
                    android:src="@drawable/tofrom" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2.2"
                android:id="@+id/leftLinear"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:weightSum="2"
                    android:id="@+id/orderleftSide">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:layout_weight="1"
                        android:layout_marginRight="@dimen/_10sdp"
                        android:layout_marginTop="@dimen/_2sdp"
                        android:id="@+id/ordelistfromLayout">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/ordelistfromName"
                            android:textSize="@dimen/_11sdp"
                            android:textStyle="bold"
                            android:maxLines="1"
                            android:ellipsize="end"
                            android:fontFamily="Ubuntu-B"
                            android:text="mazz khan"
                            android:gravity="bottom"
                            android:textColor="@color/colorBlack" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/ordelistfromNameDetail"
                            android:textSize="@dimen/_9sdp"
                            android:maxLines="1"
                            android:ellipsize="end"
                            android:textColor="@color/hint_text_color_two"
                            android:fontFamily="Ubuntu-B"
                            android:text="180-A new Muslim town Lahore"
                            android:layout_below="@+id/ordelistfromName" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:layout_marginTop="23dp"
                        android:layout_marginRight="@dimen/_10sdp"
                        android:layout_weight="1">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/ordelisttoName"
                            android:textSize="@dimen/_11sdp"
                            android:textStyle="bold"
                            android:fontFamily="Ubuntu-B"
                            android:text="mazz khan"
                            android:maxLines="1"
                            android:ellipsize="end"
                            android:textColor="@color/colorBlack" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/ordelisttoNameDetail"
                            android:textSize="@dimen/_9sdp"
                            android:fontFamily="Ubuntu-B"
                            android:textColor="@color/hint_text_color_two"
                            android:maxLines="1"
                            android:ellipsize="end"
                            android:text="180-A new Muslim town Lahore" />
                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1.2"
                android:layout_marginLeft="@dimen/_2sdp"
                android:id="@+id/rightLinear"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/date_textview"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Date"
                        android:textSize="@dimen/_10sdp"
                        android:fontFamily="Ubuntu-R"
                        android:visibility="gone"
                        android:textColor="@color/colorBlack" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/amounttext"
                        android:textSize="@dimen/_10sdp"
                        android:fontFamily="Ubuntu-R"
                        android:layout_marginTop="@dimen/_3sdp"
                        android:textColor="@color/colorBlack"
                        android:text="Amount" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/Deliverytext"
                        android:textSize="@dimen/_10sdp"
                        android:singleLine="true"
                        android:fontFamily="Ubuntu-R"
                        android:layout_marginTop="@dimen/_3sdp"
                        android:textColor="@color/colorBlack"
                        android:text="Delivery Fee" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1.8"
                android:id="@+id/rightlinearForTrackingOrder"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/ordelistDate"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/_10sdp"
                    android:textColor="@color/summery_qar_text_color_black"
                    android:fontFamily="Ubuntu-L"
                    android:visibility="gone"
                    android:text="03-02-2017"/>

                <TextView
                    android:id="@+id/ordelistamountvalue"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/_10sdp"
                    android:textColor="@color/summery_qar_text_color_black"
                    android:fontFamily="Ubuntu-L"
                    android:layout_marginTop="@dimen/_3sdp"
                    android:text="300 QR"/>
                <TextView
                    android:id="@+id/ordelistdeliveryValue"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/_10sdp"
                    android:fontFamily="Ubuntu-L"
                    android:text="20 QR"
                    android:textColor="@color/summery_qar_text_color_black"
                    android:layout_marginTop="@dimen/_3sdp" />

                <ImageView
                    android:id="@+id/ordelistRightOptionImage"
                    android:layout_width="@dimen/_14sdp"
                    android:layout_height="@dimen/_14sdp"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginTop="@dimen/_12sdp"
                    android:src="@drawable/edit" />

            </LinearLayout>

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/main_screen_line_divider"
            android:layout_below="@+id/mainLinear"
            android:layout_marginRight="@dimen/_10sdp"

            android:layout_marginLeft="@dimen/_20sdp"
            android:id="@+id/orderListRowBottomLine"
            android:orientation="horizontal">

        </View>

    </RelativeLayout>

</FrameLayout>

&lt; -these comment无用于提供标准代码描述文本 - &gt;

0 个答案:

没有答案