簡體   English   中英

布局上方

[英]Layout above another

我正在嘗試在Android應用程序中創建此頁面:

在此處輸入圖片說明

至此,我最終得到以下布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="48dp"
                android:text="My App"
                android:textAlignment="center"
                android:textColor="@android:color/white"
                android:textSize="36sp"
                android:textStyle="bold|italic"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:color/white"
            android:orientation="vertical">

        </LinearLayout>
    </LinearLayout>

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

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

        </LinearLayout>

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

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="24dp"
                android:elevation="10dp"
                app:cardCornerRadius="16dp">

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

                    <android.support.design.widget.TextInputLayout
                         android:id="@+id/default_text_layout"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent">

                     <android.support.design.widget.TextInputEditText
                         android:id="@+id/default_text"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:singleLine="true"
                         android:theme="@style/AppTheme" />
                     </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                         android:id="@+id/default_text_layout"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent">

                     <android.support.design.widget.TextInputEditText
                         android:id="@+id/default_text"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:singleLine="true"
                         android:theme="@style/AppTheme" />
                     </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                         android:id="@+id/default_text_layout"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent">

                     <android.support.design.widget.TextInputEditText
                         android:id="@+id/default_text"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:singleLine="true"
                         android:theme="@style/AppTheme" />
                     </android.support.design.widget.TextInputLayout>


                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

    </LinearLayout>

</FrameLayout>

結果是這樣的:

在此處輸入圖片說明

問題是當鍵盤對准焦點時,我得到了以下結果,將AdjustResize放在清單中:

在此處輸入圖片說明

你知不知道怎么:

1)避免在鍵盤聚焦時遮蓋輸入2)像第一個數字一樣放置按鈕(在底部邊距上方)

如果您對如何改進xml有任何建議,那將是不錯的選擇,因為我是android xml的新手。

先感謝您

1)沒有清單中的adjustSize我沒有任何問題 截圖

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="48dp"
                android:text="My App"
                android:textAlignment="center"
                android:textColor="@android:color/white"
                android:textSize="36sp"
                android:textStyle="bold|italic"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:color/white"
            android:orientation="vertical">

        </LinearLayout>
    </LinearLayout>

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

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

        </LinearLayout>

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

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="24dp"
                android:elevation="10dp"
                app:cardCornerRadius="16dp">

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

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/default_text_layout1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/default_text1"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true"
                            android:theme="@style/AppTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/default_text_layout2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/default_text2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true"
                            android:theme="@style/AppTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/default_text_layout3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/default_text3"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true"
                            android:theme="@style/AppTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/default_text_layout4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/default_text4"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true"
                            android:theme="@style/AppTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/default_text_layout5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/default_text5"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true"
                            android:theme="@style/AppTheme" />
                    </android.support.design.widget.TextInputLayout>

                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

    </LinearLayout>

</FrameLayout>

2)嘗試使用ConstraintLayoutdocs )創建平面布局而不是分層布局(這對於您的應用程序性能更好)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM