twe*_*per 270 android android-studio android-recyclerview android-tools-namespace
当我将RecyclerView添加到布局时,它显示为空白屏幕.有没有办法,比如通过tools名称空间,来显示RecyclerView内容的预览?
Phi*_*vid 601
@oRRs是对的!
我正在使用Android Studio 1.4 RC2,您现在可以指定任何自定义布局.
我尝试了一个自定义的CardView,它的工作原理.
tools:listitem="@android:layout/simple_list_item_checked"
Run Code Online (Sandbox Code Playgroud)
yoA*_*ex5 124
toolsnamespace支持设计时功能(例如在片段中显示哪种布局)或编译时行为(例如应用于XML资源的缩小模式)这是一个非常强大的功能,正在开发并允许您不能每次编译代码是时候看到变化了
GridLayoutManager示例
<!-- AndroidX -->
<androidx.recyclerview.widget.RecyclerView
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
<!-- support -->
<android.support.v7.widget.RecyclerView
tools:layoutManager="android.support.v7.widget.GridLayoutManager"
<!-- common -->
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:itemCount="5"
tools:listitem="@layout/item_video"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2" />
Run Code Online (Sandbox Code Playgroud)
引入的另一个很酷的功能Android studio 3.0是通过工具属性预定义数据,以便使用可视化的布局结构tools:text="@tools:sample/last_names".例如,您的预览将如下所示
请在此处阅读更多内容 -
https://developer.android.com/studio/write/tool-attributes.html
https://youtu.be/Hx_rwS1NTiI?list=PLWz5rJ2EKKc-odHd6XEaf7ykfsosYyCKp&t=408
https://android.jlelse.eu/Android的工具-属性-列表项样本数据岩石,bbf49aaa9f07
首先,在项目 XML 中添加以下行,以便在编辑项目时预览列表:
tools:showIn="@layout/activity_my_recyclerview_item"
Run Code Online (Sandbox Code Playgroud)
然后,在 RecyclerView XML 中添加以下行以预览您的项目在列表中的外观:
tools:listitem="@layout/adapter_item"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
72659 次 |
| 最近记录: |