【发布时间】:2020-07-13 09:42:03
【问题描述】:
My Codename One 应用必须具备 Android Chip 控件或同等功能。
它们用在两个地方,布局是:
-第一名
<com.google.android.material.chip.ChipGroup android:id="@+id/chip_group" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.google.android.material.chip.Chip android:text="@string/first_chip_title" android:id="@+id/first_chip" android:layout_width="match_parent" android:layout_height="wrap_content" app:closeIconEnabled="false"/>
<com.google.android.material.chip.Chip android:text="@string/second_chip_title" android:id="@+id/second_chip" android:layout_width="match_parent" android:layout_height="wrap_content" app:closeIconEnabled="false"/>
...
...
</com.google.android.material.chip.ChipGroup>
-第二名
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView 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/chip_list"
...
...
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:listitem="@layout/content"/>
</LinearLayout>
内容(它是 RecyclerView 的元素)在哪里:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.google.android.material.chip.Chip android:id="@+id/chip_element" android:layout_width="wrap_content" android:layout_height="wrap_content" app:closeIconEnabled="false" android:textAllCaps="false" android:layout_gravity="center_vertical" style="@style/Widget.MaterialComponents.Chip.Filter" android:layout_weight="1" />
</LinearLayout>
(一些布局参数包含在代码中,尽管它们在这里并不重要)
这是有效的布局(示例是第二种布局,第一种只是一个更简单的版本):
代号一中的等价物是什么?
【问题讨论】:
-
你能提供一个澄清的截图吗?很难将 XML 可视化。
-
@Shai Almog 是的,你现在可以看到了。
标签: android-layout android-recyclerview android-linearlayout codenameone android-chips