我正在使用 LucasR TwoWayView .我希望 View 有 2 行和多列。
就像这张图片中的第 4 张图片,除了有 2 行而不是 3 行。我尝试了很多东西但没有用。
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:id="@+id/categoryItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<org.lucasr.twowayview.TwoWayView
android:id="@+id/filterGrid"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:drawSelectorOnTop="false"
app:twowayview_numRows="3"
app:twowayview_layoutManager="GridLayoutManager" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#d3d3d3" />
</LinearLayout>
这是 Gradle 编译:
compile 'org.lucasr.twowayview:twowayview:0.1.4'
但它根本不显示 2 行。而是将所有项目排成一行。请帮忙。
最佳答案
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:id="@+id/categoryItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<org.lucasr.twowayview.TwoWayView
android:id="@+id/filterGrid"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:drawSelectorOnTop="false"
app:twowayview_numRows="3"
app:twowayview_layoutManager="GridLayoutManager" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#d3d3d3" />
</LinearLayout>
对内部 LinearLayout
使用水平方向
关于java - 无法制作两行的双向 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33388556/