scrollview,其中包含水平垂直linearlayout,权重不正常

时间:2017-07-28 05:33:38

标签: scrollview android-linearlayout android-layout-weight

[<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activityRoot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.weenggs.flora.ChoosePresentActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bkgflowerselect"
        android:orientation="vertical"
        android:weightSum="1">

        <LinearLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.15"
            android:background="@drawable/top"
            android:orientation="horizontal"
            android:visibility="visible"></LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.85"
            android:orientation="vertical">


            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="false">

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

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="0.18"
                        android:orientation="vertical">


                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:orientation="horizontal"
                            android:weightSum="1">


                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="match_parent"
                                android:layout_weight="0.5">

                                <ImageView
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:padding="10dp"
                                    android:src="@drawable/bouquet" />
                            </LinearLayout>


                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="match_parent"
                                android:layout_weight="0.5"
                                android:orientation="vertical">

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


                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="0dp"
                                        android:layout_marginBottom="15dp"
                                        android:layout_marginTop="25dp"
                                        android:layout_weight="0.8"
                                        android:background="@drawable/gradientcolor"
                                        android:elevation="15dp"
                                        android:orientation="horizontal">

                                        <LinearLayout
                                            android:layout_width="0dp"
                                            android:layout_height="match_parent"
                                            android:layout_weight="0.6"
                                            android:gravity="center|right">

                                            <TextView
                                                android:layout_width="match_parent"
                                                android:layout_height="match_parent"
                                                android:layout_marginRight="25dp"
                                                android:gravity="center|right"
                                                android:text="40$"
                                                android:textColor="@android:color/white"
                                                android:textSize="@dimen/price_text" />

                                        </LinearLayout>

                                        <LinearLayout
                                            android:layout_width="0dp"
                                            android:layout_height="match_parent"
                                            android:layout_weight="0.4">

                                            <ImageView
                                                android:layout_width="wrap_content"
                                                android:layout_height="wrap_content"
                                                android:layout_gravity="center"
                                                android:src="@drawable/flowerselectnext" />
                                        </LinearLayout>


                                    </LinearLayout>

                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="0dp"
                                        android:layout_weight="0.2">

                                        <TextView
                                            android:layout_width="match_parent"
                                            android:layout_height="match_parent"
                                            android:text="total price including SHIPPING and HANDLING "
                                            android:textSize="@dimen/below_price_text" />
                                    </LinearLayout>

                                </LinearLayout>


                            </LinearLayout>


                        </LinearLayout>

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="0.82"
                        android:orientation="vertical">

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

                            <View
                                android:layout_width="match_parent"
                                android:layout_height="1dp"
                                android:layout_marginBottom="5dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:background="#D1CFCB" />


                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_marginTop="5dp"
                                android:layout_weight="0.07"
                                android:background="#FB9D11"
                                android:elevation="5dp"
                                android:gravity="center"
                                android:text="SEND YOUR GIFT TO!"
                                android:textColor="@color/colorwhite"
                                android:textSize="20dp"
                                android:textStyle="bold" />

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_weight="0.03"></LinearLayout>

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.07"
                                android:background="@drawable/edittextdesign"
                                android:elevation="1dp"
                                android:hint="FIRST NAME , LAST NAME"
                                android:paddingBottom="10dp"
                                android:paddingLeft="10dp"
                                android:paddingTop="10dp" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.07"
                                android:background="@drawable/edittextdesign"
                                android:elevation="1dp"
                                android:hint="ADDRESS"
                                android:paddingBottom="10dp"
                                android:paddingLeft="10dp"
                                android:paddingTop="10dp" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.07"
                                android:background="@drawable/edittextdesign"
                                android:elevation="1dp"
                                android:hint="TOWN"
                                android:paddingBottom="10dp"
                                android:paddingLeft="10dp"
                                android:paddingTop="10dp" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.07"
                                android:background="@drawable/edittextdesign"
                                android:elevation="1dp"
                                android:hint="CAP"
                                android:paddingBottom="10dp"
                                android:paddingLeft="10dp"
                                android:paddingTop="10dp" />


                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="20dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.15"
                                android:background="@drawable/edittextdesign"
                                android:elevation="1dp"
                                android:gravity="top|left"
                                android:hint="Your special Message"
                                android:paddingBottom="30dp"
                                android:paddingLeft="10dp"
                                android:paddingTop="30dp"
                                android:textColorHint="#FF8800" />

                            <LinearLayout

                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.15"
                                android:orientation="horizontal">

                                <ImageView
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_weight="1.5"
                                    android:src="@drawable/clock" />

                                <EditText
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_weight="1" />
                            </LinearLayout>

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_marginBottom="15dp"
                                android:layout_marginLeft="20dp"
                                android:layout_marginRight="20dp"
                                android:layout_weight="0.15"
                                android:orientation="horizontal">

                                <ImageView
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_weight="1.5"
                                    android:src="@drawable/calendar" />

                                <EditText
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_weight="1" />
                            </LinearLayout>


                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_gravity="center"
                                android:layout_weight="0.13"
                                android:background="@drawable/footer"
                                android:gravity="center"
                                android:orientation="horizontal">

                                <LinearLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_weight="1"
                                    android:gravity="center">

                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="match_parent"
                                        android:layout_weight="1"
                                        android:gravity="center">

                                        <ImageView
                                            android:layout_width="wrap_content"
                                            android:layout_height="wrap_content"
                                            android:layout_gravity="center"
                                            android:src="@drawable/flowerselectprevious" />
                                    </LinearLayout>

                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="match_parent"
                                        android:layout_weight="1"
                                        android:gravity="center">


                                        <TextView
                                            android:layout_width="match_parent"
                                            android:layout_height="match_parent"
                                            android:layout_gravity="center"
                                            android:gravity="center|left"
                                            android:text="OPTIONS"
                                            android:textColor="@android:color/white"
                                            android:textSize="15sp"
                                            android:textStyle="bold" />
                                    </LinearLayout>

                                </LinearLayout>

                                <LinearLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_gravity="center"
                                    android:layout_weight="1"
                                    android:gravity="center">

                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="match_parent"
                                        android:layout_weight="1"
                                        android:gravity="center">

                                        <TextView
                                            android:layout_width="match_parent"
                                            android:layout_height="match_parent"
                                            android:layout_gravity="center"
                                            android:gravity="center|right"
                                            android:text="PAY NOW"
                                            android:textColor="@android:color/white"
                                            android:textSize="15sp"
                                            android:textStyle="bold" />
                                    </LinearLayout>

                                    <LinearLayout
                                        android:layout_width="match_parent"
                                        android:layout_height="match_parent"
                                        android:layout_gravity="center"
                                        android:layout_weight="1"
                                        android:gravity="center">

                                        <ImageView
                                            android:id="@+id/pay_now"
                                            android:layout_width="wrap_content"
                                            android:layout_height="wrap_content"
                                            android:layout_gravity="center"
                                            android:src="@drawable/flowerselectnext" />
                                    </LinearLayout>

                                </LinearLayout>


                            </LinearLayout>


                        </LinearLayout>


                    </LinearLayout>

                </LinearLayout>
            </ScrollView>

        </LinearLayout>

    </LinearLayout>


</LinearLayout>

**这个布局正在拉伸,但我需要低于结果**

需要滚动但不拉伸布局

正在发生的事情是布局在移动设备上运行时伸展,但在模拟器上执行与下面的图像完全相同!!

**这个布局正在拉伸,但我需要低于结果**

需要滚动但不拉伸布局

正在发生的事情是布局在移动设备上运行时伸展,但在仿真器上执行与下面的图像完全相同! Image

0 个答案:

没有答案