我的工具栏在上面。中间的Scrollview与ContraintLayout作为孩子。在ContraintLayout内部,我有一个gridview。当我添加项目时,它会向下推动页脚。我遇到了这个问题,其中relativelayout和线性布局都是root父级。它只是把一切都推下去,看不见了。我看不到页脚。一切都被推倒了。无论如何,如果我使用线性布局,我将scrollview设置为在页脚等之上或不同的权重。它总是推倒我的页脚!!!
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll_content"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fillViewport="true"
android:background="@color/colorGreen">
<android.support.constraint.ConstraintLayout
android:background="@color/colorGreen"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/GridLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:columnCount="2"
android:rowCount="6"
android:orientation="horizontal"
tools:context=".GridXMLActivity" >
<Button
android:id="@+id/button1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button7"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button8"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button9"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button10"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button11"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
<Button
android:id="@+id/button12"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left|top"
android:text="Button" />
</GridLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
THIS IS PUT INSIDE HERE:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.demoapp.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorBlack"
android:minHeight="?attr/actionBarSize">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_note_memo"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginBottom="10dp"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/icon_note_memo" />
<ImageView
android:id="@+id/iv_plus"
android:layout_width="25dp"
android:layout_height="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/icon_plus_white"
tools:layout_editor_absoluteX="283dp"
tools:layout_editor_absoluteY="0dp" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="25dp"
android:layout_height="25dp"
app:layout_constraintEnd_toStartOf="@+id/iv_plus"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/icon_search"
tools:layout_editor_absoluteX="283dp"
tools:layout_editor_absoluteY="0dp" />
<ImageView
android:id="@+id/iv_media"
android:layout_width="25dp"
android:layout_height="25dp"
app:layout_constraintEnd_toStartOf="@+id/iv_search"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/media_icons_team_white"
tools:layout_editor_absoluteX="283dp"
tools:layout_editor_absoluteY="0dp" />
<TextView
android:id="@+id/textNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Note"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toEndOf="@id/iv_note_memo" />
<!--
<android.support.constraint.Guideline
android:id="@+id/toolbarGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" /> -->
<ImageView
android:id="@+id/ivScan"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
app:layout_constraintTop_toBottomOf="@+id/iv_note_memo"
app:layout_constraintEnd_toStartOf="@+id/ivPayCode"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/iconfont_scan" />
<TextView
android:id="@+id/textScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scan"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="@id/ivScan"
app:layout_constraintTop_toBottomOf="@id/ivScan" />
<ImageView
android:id="@+id/ivPayCode"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintEnd_toStartOf="@+id/ivDiscount"
app:layout_constraintTop_toTopOf="@+id/ivScan"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ivScan"
app:srcCompat="@drawable/iconfont_paycode" />
<TextView
android:id="@+id/textPayCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pay Code"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="@id/ivPayCode"
app:layout_constraintTop_toBottomOf="@id/ivPayCode" />
<ImageView
android:id="@+id/ivDiscount"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintTop_toTopOf="@+id/ivScan"
app:layout_constraintEnd_toStartOf="@+id/ivDangmianfu"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ivPayCode"
app:srcCompat="@drawable/iconfont_discount" />
<TextView
android:id="@+id/textDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discount"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="@id/ivDiscount"
app:layout_constraintTop_toBottomOf="@id/ivDiscount" />
<ImageView
android:id="@+id/ivDangmianfu"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintTop_toTopOf="@+id/ivScan"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ivDiscount"
app:srcCompat="@drawable/iconfont_dangmianfu_yellow" />
<TextView
android:id="@+id/textDianmianful"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mianfu"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="@id/ivDangmianfu"
app:layout_constraintTop_toBottomOf="@id/ivDiscount" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<include
layout="@layout/scroll_content"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.constraint.ConstraintLayout 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/footer"
android:layout_below="@+id/scroll_content"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<ImageView
android:id="@+id/iv_front_huabei"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintEnd_toStartOf="@+id/iv_confont_koubeilogo"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/iconfont_huabei" />
<ImageView
android:id="@+id/iv_confont_koubeilogo"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintEnd_toStartOf="@+id/iv_icon_social_team_black"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_front_huabei"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/iconfont_koubeilogo" />
<ImageView
android:id="@+id/iv_icon_social_team_black"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintEnd_toStartOf="@+id/iv_iconfont_zhuanzhang"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_confont_koubeilogo"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/icon_social_team_black" />
<Button
android:id="@+id/unredMsgButton"
app:layout_constraintStart_toEndOf="@+id/iv_icon_social_team_black"
app:layout_constraintTop_toTopOf="@+id/iv_icon_social_team_black"
android:background="@drawable/circle"
android:text="2"
android:textColor="@color/colorWhite"
android:layout_width="25dp"
android:layout_height="25dp"
app:srcCompat="@drawable/circle_red" />
<ImageView
android:id="@+id/iv_iconfont_zhuanzhang"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_icon_social_team_black"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/iconfont_zhuanzhang" />
</android.support.constraint.ConstraintLayout>
</RelativeLayout>