Recycler View Grid Layout Manager中的问题,

时间:2018-11-25 11:10:05

标签: android gridlayoutmanager

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

I have created A Grid Layout Like this

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

But I Want My grid Layout some thing like this

我希望我的文字显示在右侧。像联系人列表。请告诉我我必须在布局文件中进行哪些更改。等待一个好的回应。

3 个答案:

答案 0 :(得分:0)

尝试将线性布局的方向更改为水平。

答案 1 :(得分:0)

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

有关示例,请参见official documentation

答案 2 :(得分:-1)

此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>
相关问题