【问题标题】:Problem In Recycler View Grid Layout Manager,回收站视图网格布局管理器中的问题,
【发布时间】:2018-11-25 11:10:04
【问题描述】:

我已经创建了一个像这样的网格布局:

但我希望我的网格布局是这样的:

我希望我的文字出现在右侧。喜欢联系人列表。请告诉我必须对布局文件进行哪些更改。等待好的回应。

【问题讨论】:

  • 感谢@TrebuchetMs 纠正我...
  • 不用担心,这是审核过程的一部分。由于images of code,我可以预见你的反对意见。我建议你 copy-paste your code into your questionformat it 让它看起来像。 :-)
  • @TrebuchetMS 很抱歉给您带来不便,我是堆栈溢出的新手。这是我的第一个问题。所以我不太熟悉堆栈溢出的规则和规定。下次会记住这一点。

标签: android gridlayoutmanager


【解决方案1】:

由于您似乎想要一个列表而不是网格,因此您应该使用 LinearLayoutManager,而不是 GridLayoutManager。

有关示例,请参阅official documentation

【讨论】:

    【解决方案2】:

    尝试将 linerlayout 的方向更改为水平。

    【讨论】:

      【解决方案3】:

      这个xml代码只是复制过去

      <?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:id="@+id/android_list_view_tutorial_with_example"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:orientation="horizontal"
      android:padding="5dp">
      
      <ImageView
          android:id="@+id/album"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:contentDescription="@string/app_name"
          android:padding="5dp"
          android:src="@drawable/pic1" />
      
      <TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="YOUR TEXT"
          android:id="@+id/album_title">
      </TextView>
      </LinearLayout>
      

      【讨论】:

      • 非常感谢@Abdomns。这确实解决了我的问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 2016-07-04
      • 1970-01-01
      相关资源
      最近更新 更多