android - 哪些布局元素用于以下类型的布局
问题描述
我当然是新手,Andorid Development
并且对基本的东西有一定的了解,,,,,等等....Relative Layout
Linear Layout
Intent
File Handling
我需要构建一个类似于 some 的项目E-commerce app
。这是我想要的图像。
我如何获得给定的产品视图,就像在博客或其他网站中一样。我必须使用List View
吗?
请告诉我必须使用什么来制作“ Add Filter Tags
”部分以及如何实现我在图片中显示的内容。
解决方案
下面是将为您的 UI 要求创建骨架的代码。您可以根据需要对其进行修改。
您的 Activity/Fragment xml 将如下所示:
<?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">
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<com.google.android.material.chip.ChipGroup
android:id="@+id/entry_chip_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/cl_parent">
</com.google.android.material.chip.ChipGroup>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/entry_chip_group"
/>
</android.support.constraint.ConstraintLayout>
RecyclerView 的适配器 xml 将如下所示:
<?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="wrap_content">
<ImageView
android:id="@+id/iv_product"
android:layout_width="100dp"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Product Name"
app:layout_constraintStart_toEndOf="@id/iv_product"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Product Information"
app:layout_constraintStart_toStartOf="@id/tv_name"
app:layout_constraintTop_toBottomOf="@id/tv_name" />
<TextView
android:id="@+id/tv_more_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="More info"
app:layout_constraintStart_toStartOf="@id/tv_name"
app:layout_constraintTop_toBottomOf="@id/tv_info" />
<TextView
android:id="@+id/tv_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data"
app:layout_constraintStart_toStartOf="@id/tv_name"
app:layout_constraintTop_toBottomOf="@id/tv_more_info" />
<TextView
android:id="@+id/tv_tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tags"
app:layout_constraintStart_toStartOf="@id/tv_name"
app:layout_constraintTop_toBottomOf="@id/tv_data" />
</android.support.constraint.ConstraintLayout>
你应该使用Chips
你的过滤器标签。您可以将它们动态添加到您的chip group
. 以下是供参考的链接。
推荐阅读
- java - Javafx ExceptionInInitializerError
- c - 将 pthread.h 添加到 nds 项目 makefile
- php - 相同布局的两个页面不同的文本
- assembly - 在 x86-64 中仅使用 16 个寄存器跟踪调用者和被调用者函数
- android - React Native 应用程序崩溃:无法从资产“index.android.bundle”加载脚本
- mongodb - 如何在 MongoDB 中将数组位置 $ 与聚合投影一起使用
- networking - 办公室网络设置
- android - Unity 到 Android - apk 安装但不运行
- java - 将 java.time.LocalDate 与 postgres 日期进行比较的问题
- php - php用参数调用python脚本但没有输出