当我将RecyclerView添加到布局时,它显示为空白屏幕.有没有办法,比如通过tools名称空间,来显示RecyclerView内容的预览?
android android-studio android-recyclerview android-tools-namespace
这是一个基本的android问题.我有app需要为手机和平板电脑设置不同的屏幕.手机需要有一个ListView,平板电脑需要有一个GridView的项目.
我想知道如何在不制作两个不同的应用程序的情况下做到这一点.
谢谢
如何使用kotlin将layoutmanager设置为RecycleView作为以下java代码:
mRecyclerView.setLayoutManager(mLinearLayoutManager);
我有 2 个回收者视图。1 个水平和 1 个垂直。在设计页面中,第一个回收器的元素是水平的,第二个回收器的元素是垂直的,但是当我运行应用程序时,它们都是垂直的,我无法弄清楚问题是什么。
  <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/selected_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/name_edit_text"
        tools:listItem="@layout/item_participant_selected" />
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="120dp"
        android:layout_marginBottom="@dimen/participants_padding_bottom"
        android:clipToPadding="false"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="@id/selected_recycler_view"
        app:layout_constraintStart_toStartOf="@id/selected_recycler_view"
        app:layout_constraintTop_toBottomOf="@id/selected_recycler_view"
        tools:listItem="@layout/item_participant" />