0

введите сюда описание изображения

Я хочу сделать так, чтобы кнопка всегда была впереди всех, как на CSS... Сейчас ее закрывает нижний LinearLayout. Как это сделать?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color"
    android:orientation="vertical"
    android:weightSum="10">


    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="160dp"
        android:id="@+id/topLayout">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView"
            android:src="@drawable/header"
            android:scaleType="centerCrop"
            android:contentDescription="@string/headImage" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="@dimen/stndHeight"
            android:background="#20ffffff"
            android:layout_gravity="bottom|center"
            android:gravity="center_vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/title1"
                android:id="@+id/tvTitle1"
                android:textColor="@color/titleEnableColor"
                android:layout_weight="1"
                android:gravity="center"
                style="@style/mainTextStyle" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/title2"
                android:id="@+id/tvTitle2"
                android:textColor="@color/titleDisableColor"
                android:layout_weight="1"
                android:gravity="center"
                style="@style/mainTextStyle" />
        </LinearLayout>

    </FrameLayout>
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/mainLayout">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_marginBottom="@dimen/exchangePosition"
            android:paddingLeft="@dimen/leftPadding"
            android:paddingRight="@dimen/textMargin"
            android:background="@drawable/linear_click"
            android:clickable="true">

            <ImageView
                android:layout_width="@dimen/iconsSize"
                android:layout_height="@dimen/iconsSize"
                android:src="@drawable/from"
                android:contentDescription="@string/iconFrom" />

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:layout_marginLeft="@dimen/leftPadding">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="@string/from"
                    android:id="@+id/tvFrom"
                    android:gravity="center_vertical"
                    style="@style/mainTextStyle" />
            </LinearLayout>
        </LinearLayout>

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

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/horLineHeight"
                android:background="@color/vColor"
                android:layout_gravity="center"
                android:layout_weight="2">
            </View>

            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:measureAllChildren="false"
                android:nestedScrollingEnabled="false"
                android:transitionGroup="false"
                android:touchscreenBlocksFocus="false"
                android:focusableInTouchMode="false"
                android:outlineProvider="bounds">

                <Button
                    android:layout_width="@dimen/smallIconSize"
                    android:layout_height="@dimen/smallIconSize"
                    android:id="@+id/button"
                    android:background="@drawable/icon_click"
                    android:layout_marginRight="@dimen/rightPadding"
                    android:allowUndo="false"
                    android:focusableInTouchMode="false"
                    android:nestedScrollingEnabled="false" />
            </FrameLayout>

        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginTop="@dimen/exchangePosition"
            android:paddingLeft="@dimen/leftPadding"
            android:paddingRight="@dimen/textMargin"
            android:clickable="true"
            android:background="@drawable/linear_click">

            <ImageView
                android:layout_width="@dimen/iconsSize"
                android:layout_height="@dimen/iconsSize"
                android:id="@+id/imageView3"
                android:src="@drawable/to"
                android:contentDescription="@string/iconFlyTo" />

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:layout_marginLeft="@dimen/leftPadding">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:text="@string/to"
                    android:id="@+id/tvTo"
                    android:singleLine="false"
                    style="@style/mainTextStyle"
                    android:gravity="center_vertical" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/horLineHeight"
            android:background="@color/vColor"
            android:layout_weight="2"
            android:layout_gravity="center">
        </View>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:paddingLeft="@dimen/leftPadding"
            android:paddingRight="@dimen/textMargin">

            <ImageView
                android:layout_width="@dimen/iconsSize"
                android:layout_height="@dimen/iconsSize"
                android:id="@+id/imageView2"
                android:src="@drawable/calendar"
                android:contentDescription="@string/iconCalendar" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="@string/vylet"
                android:id="@+id/tvDepart"
                android:gravity="center_vertical"
                android:layout_marginLeft="@dimen/leftPadding"
                android:layout_weight="1"
                style="@style/mainTextStyle" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="@dimen/lineHeight"
                android:id="@+id/imageView4"
                android:src="@drawable/separate_line" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="@string/prilet"
                android:id="@+id/tvArrive"
                android:gravity="center_vertical|center_horizontal"
                android:layout_weight="1"
                style="@style/mainTextStyle" />
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/horLineHeight"
            android:background="@color/vColor"
            android:layout_weight="2"
            android:layout_gravity="center">
        </View>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingRight="@dimen/textMargin"
            android:paddingLeft="@dimen/leftPadding">

            <ImageView
                android:layout_width="@dimen/iconsSize"
                android:layout_height="@dimen/iconsSize"
                android:id="@+id/imageView5"
                android:src="@drawable/passenger"
                android:contentDescription="@string/iconPassenger" />

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:layout_marginLeft="@dimen/leftPadding">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/passengers"
                    android:id="@+id/tvPassengers"
                    style="@style/mainTextStyle" />

                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:baselineAligned="false">

                    <LinearLayout
                        android:orientation="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="3"
                        android:gravity="left">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/oldPassengers"
                            android:id="@+id/tvOldPass"
                            android:layout_marginRight="@dimen/textMargin"
                            style="@style/smallText" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/oldPassengersCount"
                            android:id="@+id/tvOldPassCount"
                            style="@style/smallText" />
                    </LinearLayout>

                    <LinearLayout
                        android:orientation="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="4"
                        android:gravity="left|center_horizontal">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/childPassengers"
                            android:id="@+id/tvChildPass"
                            android:layout_marginRight="@dimen/textMargin"
                            style="@style/smallText" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/childPassengersCount"
                            android:id="@+id/tvChildPassCount"
                            style="@style/smallText" />
                    </LinearLayout>

                    <LinearLayout
                        android:orientation="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="3"
                        android:gravity="center_horizontal">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/babyPassengers"
                            android:id="@+id/textView10"
                            android:layout_marginRight="@dimen/textMargin"
                            style="@style/smallText" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/babyPassengersCount"
                            android:id="@+id/textView13"
                            style="@style/smallText" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/horLineHeight"
            android:background="@color/vColor"
            android:layout_weight="2"
            android:layout_gravity="center">
        </View>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_vertical"
            android:paddingLeft="@dimen/leftPadding"
            android:paddingRight="@dimen/textMargin">

            <ImageView
                android:layout_width="@dimen/iconsSize"
                android:layout_height="@dimen/iconsSize"
                android:id="@+id/imageView6"
                android:src="@drawable/classy"
                android:contentDescription="@string/iconClass"
                android:background="@drawable/classy" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="@string/busClass"
                android:id="@+id/textView14"
                android:gravity="center_vertical"
                android:layout_marginLeft="@dimen/leftPadding"
                android:layout_weight="1"
                style="@style/mainTextStyle" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="@dimen/lineHeight"
                android:id="@+id/imageView7"
                android:src="@drawable/separate_line"
                android:contentDescription="@string/iconLineSep" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="@string/ecClass"
                android:id="@+id/textView15"
                android:gravity="center_vertical|center_horizontal"
                android:layout_weight="1"
                style="@style/mainTextStyle" />
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/horLineHeight"
            android:background="@color/vColor"
            android:layout_weight="2"
            android:layout_gravity="center">
        </View>

    </LinearLayout>
    </ScrollView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:paddingRight="@dimen/textMargin"
        android:paddingLeft="@dimen/leftPadding"
        android:paddingBottom="@dimen/textMargin"
        android:gravity="bottom">

        <Button
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:id="@+id/btnSearch"
            android:layout_alignParentBottom="true"
            style="@style/btnStyle"
            android:gravity="center" />
    </RelativeLayout>

</LinearLayout>
9
  • Вам поможет FrameLayout. Как им пользоваться, вы можете найти в любом курсе уроков по Android 22 янв 2016 в 10:44
  • ок! Я добавил framelayout но проблема та же! ничего не изменилось!
    – DevOma
    22 янв 2016 в 10:51
  • добавьте разметку. Используете ли Вы RelativeLayout? 22 янв 2016 в 10:52
  • Нет! Не использую!
    – DevOma
    22 янв 2016 в 10:54
  • Подскажите, пожалуйста! Из за маленькой проблемы нет времени на поиски видеоуроков по Frame
    – DevOma
    22 янв 2016 в 10:55

1 ответ 1

0

Сложная у Вас верстка. Вот как бы я отрисовал Ваш элемент.

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    <TextView android:id="@+id/from"
        android:layout_height="wrap_content"
        android:drawablePadding="5dp"
        android:drawableLeft="@drawable/icon_from"
        android:layout_width="wrap_content"/>
    <TextView android:id="@+id/to"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/icon_to"
        android:drawablePadding="5dp"
        android:layout_width="wrap_content"/>
    </LinearLayout>
    <ImageView android:id="@+id/change"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"/>
    </RelativeLayout>

Принцип, думаю, понятен.

3
  • то есть мой никак нельзя переделать...?
    – DevOma
    22 янв 2016 в 15:28
  • Сделал, как бэ помогло но верхний linearLayout на половину изчес ибо нижний Linear закрыл его нижнюю половину! как быть?
    – DevOma
    23 янв 2016 в 8:39
  • Сложная, это ещё очень мягко сказано. 23 янв 2016 в 12:11

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.