android - 最后一项左对齐
问题描述
我正在使用 Google 的官方 Flexbox 实现来对齐正方形,我想知道是否可以将最后一项对齐到左侧。我尝试使用 app:justifyContent="flex_start" 但它并不适合所有屏幕,例如 app:justifyContent="space_between"。我搜索但一无所获。你能帮助我吗?这是屏幕的图像,这是代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:justifyContent="space_between"
app:flexWrap="wrap"
android:layout_margin="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@color/colorPrimary"
android:layout_margin="4dp"/>
</com.google.android.flexbox.FlexboxLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
解决方案
推荐阅读
- bash - {1} 在 |master {1} 中是什么意思 ✓| 与 bashit?
- .net - 在 EF Core 中查询多对多关系,以便结果 SQL 查询使用 JOIN
- c++ - QListWidget 的 editItem() 输出“编辑:编辑失败”
- swiftui - 更简单的 ViewModel 实现
- c++ - 创建程序以从给定的 .txt 文件中查找文本,替换并计算单词
- python - 为什么 pytorch 需要比它应该的更多的内存?
- java - 如果用户输入错误的数字或在用户输入“1”时重新开始,我该如何制作它?
- asp.net - 如何在asp.net中录制视频
- docker - 为什么我在完全更新的 azerothcore 下载时遇到 docker-compose 版本冲突?
- python - 如何以有序的方式绘制 k-means 聚类结果