帧布局换行内容问题

时间:2018-04-05 10:56:29

标签: android xml android-layout

我有一个抽象布局,其中包含一个具有属性包装内容的框架布局,问题是框架布局没有包装它的所有子项,它会在屏幕外切割一些。我更喜欢使用Constraint Layout作为抽屉布局的一个孩子,因为我不仅需要一个抽屉,而且Constraint Layout在手机内存上也很容易使用。这是我的代码。

This is what I want it to look like..

This is what it looks like currently

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.tejas.uno.MainActivity"
android:background="@color/background_color"
android:layout_gravity="center">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >


    <android.support.constraint.ConstraintLayout
        android:id="@+id/UI_Holder"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            android:id="@+id/Menu_toolbar"
            layout="@layout/toolbar"
            android:layout_width="0dp"
            android:layout_height="56dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.constraint.Barrier
            android:id="@+id/barrier3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="bottom"
            app:constraint_referenced_ids="SinglePlayer_cardView,Gamemode_cardView"
            tools:ignore="MissingConstraints"
            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="179dp" />

        <android.support.constraint.Guideline
            android:id="@+id/Vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.5" />

        <android.support.constraint.Barrier
            android:id="@+id/barrier4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="bottom"
            app:constraint_referenced_ids="Multiplayer_cardView,Multiplayer_Gamemode_cardView"
            tools:ignore="MissingConstraints"
            tools:layout_editor_absoluteY="567dp" />

        <android.support.constraint.Guideline
            android:id="@+id/guideline2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_begin="250dp" />

        <android.support.constraint.Guideline
            android:id="@+id/guideline3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_begin="443dp" />

        <android.support.constraint.Guideline
            android:id="@+id/guideline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_begin="57dp" />


        <android.support.v7.widget.CardView
            android:id="@+id/SinglePlayer_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:background="?android:attr/selectableItemBackground"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintBottom_toBottomOf="@id/guideline2"
            app:layout_constraintEnd_toEndOf="@id/Vertical"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/Menu_toolbar">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="?android:attr/selectableItemBackground">

                <ImageView
                    android:id="@+id/SInglePlayer_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_margin="10dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:background="@drawable/green_circle"
                    android:contentDescription="@string/Content_des_single_player_icon"
                    android:padding="10dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_person_white_24dp" />

                <TextView
                    android:id="@+id/SinglePlayer_txt"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:gravity="center"
                    android:text="@string/single_player_btn_txt"
                    android:textAllCaps="true"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/SInglePlayer_img" />

                <View
                    android:id="@+id/SinglePlayer_view"
                    android:layout_width="0dp"
                    android:layout_height="1dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="16dp"
                    android:background="@color/gray_line"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/SinglePlayer_txt" />

                <TextView
                    android:id="@+id/SinglePlayer_description"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginTop="8dp"
                    android:gravity="center_vertical"
                    android:text="@string/SinglePlayer_txt_description"
                    android:textAlignment="center"
                    android:textColor="@android:color/darker_gray"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/SinglePlayer_view" />

            </android.support.constraint.ConstraintLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            android:id="@+id/Gamemode_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintBottom_toTopOf="@+id/guideline2"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@+id/Vertical"
            app:layout_constraintTop_toBottomOf="@id/Menu_toolbar">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/Gamemode_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginLeft="16dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:background="@drawable/pink_circle"
                    android:contentDescription="@string/Gamemodes_icon_description"
                    android:padding="10dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_games_white_24dp" />

                <TextView
                    android:id="@+id/Gamemode_txt"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="16dp"
                    android:layout_marginLeft="16dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/Gamemode_btn_txt"
                    android:textAlignment="center"
                    android:textAllCaps="true"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Gamemode_img" />

                <View
                    android:id="@+id/Gamemode_view"
                    android:layout_width="0dp"
                    android:layout_height="1dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="16dp"
                    android:background="@color/gray_line"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Gamemode_txt" />

                <TextView
                    android:id="@+id/Gamemode_description"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginTop="8dp"
                    android:gravity="center_vertical"
                    android:text="@string/Gamemode_txt_description"
                    android:textAlignment="center"
                    android:textColor="@android:color/darker_gray"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Gamemode_view" />
            </android.support.constraint.ConstraintLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            android:id="@+id/Multiplayer_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toTopOf="@+id/guideline3"
            app:layout_constraintEnd_toStartOf="@+id/Vertical"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/barrier3">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/Multiplayer_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginLeft="16dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:background="@drawable/purple_circle"
                    android:contentDescription="@string/Multiplayer_icon_description"
                    android:padding="10dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_people_white_24dp" />

                <TextView
                    android:id="@+id/Mulltiplayer_title_txt"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/Multiplayer_txt"
                    android:textAlignment="center"
                    android:textAllCaps="true"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Multiplayer_img" />

                <View
                    android:id="@+id/Multiplayer_view"
                    android:layout_width="0dp"
                    android:layout_height="1dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="16dp"
                    android:background="@color/gray_line"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Mulltiplayer_title_txt" />

                <TextView
                    android:id="@+id/Multiplayer_description"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginTop="8dp"
                    android:gravity="center_vertical"
                    android:text="@string/Multiplayer_description"
                    android:textAlignment="center"
                    android:textColor="@android:color/darker_gray"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Multiplayer_view" />
            </android.support.constraint.ConstraintLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            android:id="@+id/Multiplayer_Gamemode_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toTopOf="@+id/guideline3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@+id/Vertical"
            app:layout_constraintTop_toTopOf="@id/barrier3">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/Multiplayer_Gamemode_cardView_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:background="@drawable/yellow_circle"
                    android:contentDescription="@string/Multiplayer_gamemode_icon_description"
                    android:padding="10dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_games_white_24dp" />

                <TextView
                    android:id="@+id/Multiplayer_Gamemode_txt"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/Multiplayer_gamemode_txt"
                    android:textAlignment="center"
                    android:textAllCaps="true"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Multiplayer_Gamemode_cardView_img" />

                <View
                    android:id="@+id/Multiplayer_Gamemode_view"
                    android:layout_width="0dp"
                    android:layout_height="1dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="16dp"
                    android:background="@color/gray_line"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Multiplayer_Gamemode_txt" />

                <TextView
                    android:id="@+id/Multiplayer_Gamemode_description"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginTop="8dp"
                    android:gravity="center_vertical"
                    android:text="@string/Multiplayer_Gamemodes_description"
                    android:textAlignment="center"
                    android:textColor="@android:color/darker_gray"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/Multiplayer_Gamemode_view" />
            </android.support.constraint.ConstraintLayout>
        </android.support.v7.widget.CardView>

        <RelativeLayout
            android:id="@+id/Settings_Holder"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@id/barrier4">

            <android.support.constraint.ConstraintLayout
                android:id="@+id/Settings_Object"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/Settings_img"
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:layout_marginLeft="24dp"
                    android:layout_marginStart="24dp"
                    android:background="@drawable/pink_circle"
                    android:contentDescription="@string/Settings_icon_description"
                    android:elevation="15dp"
                    android:padding="10dp"
                    app:layout_constraintBottom_toTopOf="@+id/Settings_cardView"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="@id/Settings_cardView"
                    app:layout_constraintVertical_bias="0.531"
                    app:srcCompat="@drawable/ic_settings_white_24dp"
                    tools:ignore="RtlHardcoded" />

                <android.support.v7.widget.CardView
                    android:id="@+id/Settings_cardView"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginTop="40dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_bias="1.0"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="1.0">

                    <android.support.constraint.ConstraintLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/Settings_txt"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="8dp"
                            android:layout_marginStart="8dp"
                            android:layout_marginTop="40dp"
                            android:text="@string/Settings_txt"
                            android:textAllCaps="true"
                            android:textSize="24sp"
                            android:textStyle="bold"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:ignore="RtlHardcoded" />

                        <View
                            android:id="@+id/Settings_view"
                            android:layout_width="0dp"
                            android:layout_height="1dp"
                            android:layout_marginEnd="8dp"
                            android:layout_marginLeft="8dp"
                            android:layout_marginRight="8dp"
                            android:layout_marginStart="8dp"
                            android:layout_marginTop="16dp"
                            android:background="@color/gray_line"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toBottomOf="@+id/Settings_txt" />

                        <TextView
                            android:id="@+id/Settings_description"
                            android:layout_width="0dp"
                            android:layout_height="0dp"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center_vertical"
                            android:text="@string/Settings_description"
                            android:textAlignment="center"
                            android:textColor="@android:color/darker_gray"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toBottomOf="@+id/Settings_view" />
                    </android.support.constraint.ConstraintLayout>
                </android.support.v7.widget.CardView>
            </android.support.constraint.ConstraintLayout>
        </RelativeLayout>


    </android.support.constraint.ConstraintLayout>

</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/Nav"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:menu="@menu/nav_menu" />

请帮帮我。谢谢!

0 个答案:

没有答案