rainboy2010

我们在布局文件里定义RecyclerView时,可以使用tools属性预览数据,如下:

    <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:itemCount="10"
            tools:layoutManager="LinearLayoutManager"
            tools:listitem="@layout/item_person_info"
            tools:orientation="vertical" />

item_person_info文件定义如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
        android:layout_height="50dp">

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            tools:text="@tools:sample/full_names" />

    <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            tools:src="@tools:sample/avatars" />
</android.support.constraint.ConstraintLayout>

预览效果如下:

将tools:layoutManager的值改为GridLayoutManager,预览效果如下:

 

 

 

 

 


 

分类:

技术点:

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2021-04-15
  • 2021-07-25
  • 2019-07-09
  • 2021-11-06
  • 2021-08-03
  • 2021-04-14
猜你喜欢
  • 2021-10-22
  • 2021-06-23
  • 2021-08-10
  • 2021-08-27
  • 2021-12-12
  • 2021-09-27
相关资源
相似解决方案