Java 从底部对齐后视镜儿童

Java 从底部对齐后视镜儿童,java,android,xml,kotlin,layout,Java,Android,Xml,Kotlin,Layout,我想用Recyerview制作图表。我遇到的问题是,我似乎无法使子项从底部对齐,而不是从ReclayerView的顶部对齐 我已经试过了,把你和斯塔克弗伦德颠倒过来 我到处找了。我仍然不知道为什么会这样 谁能帮帮我吗。 任何有用的想法都将不胜感激 我有点明白了 因为我有静态高度,所以我在孩子周围创建了另一个包装,它被连接到底部,并且帕朗特设置为特定高度 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="htt

我想用Recyerview制作图表。我遇到的问题是,我似乎无法使子项从底部对齐,而不是从ReclayerView的顶部对齐

我已经试过了,把你和斯塔克弗伦德颠倒过来

我到处找了。我仍然不知道为什么会这样

谁能帮帮我吗。
任何有用的想法都将不胜感激

我有点明白了

因为我有静态高度,所以我在孩子周围创建了另一个包装,它被连接到底部,并且帕朗特设置为特定高度

<androidx.constraintlayout.widget.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="80dp"
        android:layout_height="200dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginRight="8dp"
        >

<androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">


        <TextView
                android:id="@+id/tv_time"
                style="@style/BoldWhiteText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="7.5"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
 </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

默认情况下,布局管理器将项目与顶部开始对齐,因为在RecyclerView具有可能导致某些布局问题的包裹内容高度的情况下,它是最稳定的

如果您的RecyclerView具有固定大小,您可以尝试扩展正在使用的布局管理器,以强制其在底部布局项目:

// inside your activity or fragment where you're initializing RecyclerView
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) {
      @Override
      public void layoutDecoratedWithMargins(@NonNull View child, int left, int top, int right, int bottom) {
          // calculate available space in recyclerView
          int offset = getHeight() - getPaddingTop() - getPaddingBottom();
          // subtract height of item being laid out
          offset -= bottom - top;
          // lay out item lower than usual
          super.layoutDecoratedWithMargins(child, left, top + offset, right, bottom + offset);
      }
});

将视图固定器设置为相对布局,然后将内容对齐到底部并不能解决问题?@Medeiros我曾尝试将孩子的父视图对齐到底部,但似乎没有任何效果