将ConstraintLayout中的FrameLayout对齐到底部

Pri*_*ish 12 xml android android-layout android-view android-constraintlayout

我希望屏幕底部的回收视图上方有一个布局(如框架),这样即使该布局可见,我仍然可以在其后面滚动回收视图.所以我想在屏幕底部对齐框架布局并制作它根据要求可见和不可见.这是我的代码.

 <?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.protossoft.root.aesencryption.MainActivity">



    <ListView
        android:layout_width="match_parent"
        android:id="@+id/listView"
        android:layout_height="match_parent">

    </ListView>

  <!--  <RelativeLayout
        android:layout_width="match_parent"

        android:layout_height="wrap_content">-->
    <FrameLayout
        android:layout_width="match_parent"

        android:layout_height="wrap_content"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="443dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:gravity="center"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/deviceNumberImage"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.2"
                android:src="@android:drawable/btn_default" />

            <TextView
                android:id="@+id/deviceNumber"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.8"
                android:text="990000862471854" />

        </LinearLayout>
    </FrameLayout>
   <!-- </RelativeLayout>-->
Run Code Online (Sandbox Code Playgroud)

我对约束布局没有太多的想法,但是当我从编辑器底部移动视图时,它正在使用像

tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="443dp"
Run Code Online (Sandbox Code Playgroud)

我想用align_parentBottom这样的属性实现相同的功能.但是没有一个属性可供使用.我需要做什么才能使框架布局同时在回收器视图的底部和顶部可见?谢谢 :)

azi*_*ian 26

我想用align_parentBottom这样的属性实现相同的功能.

你应该使用app:layout_constraintEnd_toEndOf="parent"属性.

这是您需要的设置:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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">

    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">
        ...
    </FrameLayout>

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)