java - 无法制作两行的双向 View

标签 java android android-layout

我正在使用 LucasR TwoWayView .我希望 View 有 2 行和多列。

enter image description here

就像这张图片中的第 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/

相关文章:

java - 如何使用方法测试java类

java - LIBGDX - 创建音乐时出错

java - 将 Sugar ORM 与 UUID 或 Joda-Time 结合使用

java - 如何在单击 ListView 项目时出现勾号并且不会消失,直到单击的下一个项目在转到另一个 Activity 时也不会消失

java - 在 Spring 项目中实现 JSR-303 注释

java - 我可以在不关闭和重新打开 Java 套接字的情况下更改我正在使用的流类型吗?

android - 使用 Android APK 2.2 打开硬件加速(如 Android 3+)

安卓 2.1 漏洞 : uses res/layout-v3 instead of res/layout

java - 如何清除searchview中的recyclerview/adapter以进行下一次搜索android

android - 工具栏中的自定义布局未显示