美文网首页
RecyclerView 布局快速看效果

RecyclerView 布局快速看效果

作者: 雨来 | 来源:发表于2021-09-22 11:28 被阅读0次

tools:在xml布局中 只是临时展示作用 并不参与代码的编译功能,实际运行是无效果的
之前用得最多的是 这个两个属性:

 tools:itemCount="2"
 tools:listitem="@layout/item_lable_common_big_brother"

如果要看设置layoutManager的话则要引入app命名空间:

                    <androidx.recyclerview.widget.RecyclerView
                    tools:itemCount="2"
                    tools:listitem="@layout/item_lable_common_big_brother"
                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    tools:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"></androidx.recyclerview.widget.RecyclerView>

还有哪些属性可以用呢?一般只要我们可以通过代码设置的都可以通过tools来预览的
可以看一下RecyclerView 库的aar文件:


image.png
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr format="reference" name="recyclerViewStyle"/>
    <dimen name="fastscroll_default_thickness">8dp</dimen>
    <dimen name="fastscroll_margin">0dp</dimen>
    <dimen name="fastscroll_minimum_range">50dp</dimen>
    <dimen name="item_touch_helper_max_drag_scroll_per_frame">20dp</dimen>
    <dimen name="item_touch_helper_swipe_escape_max_velocity">800dp</dimen>
    <dimen name="item_touch_helper_swipe_escape_velocity">120dp</dimen>
    <item name="item_touch_helper_previous_elevation" type="id"/>
    <declare-styleable name="RecyclerView">
        <!-- Class name of the Layout Manager to be used.
        <p/>
        The class must ext androidx.recyclerview.widget.RecyclerViewView$LayoutManager
        and have either a default constructor or constructor with the signature
        (android.content.Context, android.util.AttributeSet, int, int).
         <p/>
         If the name starts with a '.', application package is prefixed.
         Else, if the name contains a '.', the classname is assumed to be a full class name.
         Else, the recycler view package naandroidx.appcompat.widgetdget) is prefixed. -->
        <attr format="string" name="layoutManager"/>

        <!-- ============================= -->
        <!-- Attributes for Layout Manager -->
        <!-- ============================= -->
        <eat-comment/>

        <attr name="android:orientation"/>
        <attr name="android:descendantFocusability"/>
        <attr name="android:clipToPadding"/>
        <attr format="integer" name="spanCount"/>
        <attr format="boolean" name="reverseLayout"/>
        <attr format="boolean" name="stackFromEnd"/>
        <attr format="boolean" name="fastScrollEnabled"/>
        <attr format="reference" name="fastScrollVerticalThumbDrawable"/>
        <attr format="reference" name="fastScrollVerticalTrackDrawable"/>
        <attr format="reference" name="fastScrollHorizontalThumbDrawable"/>
        <attr format="reference" name="fastScrollHorizontalTrackDrawable"/>
    </declare-styleable>
</resources>

相关文章

网友评论

      本文标题:RecyclerView 布局快速看效果

      本文链接:https://www.haomeiwen.com/subject/lxwwgltx.html