AbstractListView源码分析5

本文深入解析了Android中ListView的Selector机制,包括Selector的绘制位置、使用的Drawable资源、当前选择的位置等核心属性。同时介绍了ListView的缓存机制以及Selector在绘制过程中的定位与尺寸设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    /**
     * Indicates whether the list selector should be drawn on top of the children or behind
     */

    boolean mDrawSelectorOnTop = false;  表明了list selector是否应该绘制在children的顶部还是后面


   /**
     * The drawable used to draw the selector
     */
    Drawable mSelector;分隔符的图片


    /**
     * The current position of the selector in the list.
     */
    int mSelectorPosition = INVALID_POSITION; 目前选择selector的位置


    /**
     * Defines the selector's location and dimension at drawing time
     */
    Rect mSelectorRect = new Rect(); 定义selector的位置和区域在绘制时


    /**
     * The data set used to store unused views that should be reused during the next layout
     * to avoid creating new ones
     */
    final RecycleBin mRecycler = new RecycleBin(); Listview的缓存机制


   /**
     * The selection's left padding
     */
    int mSelectionLeftPadding = 0;


    /**
     * The selection's top padding
     */
    int mSelectionTopPadding = 0;


    /**
     * The selection's right padding
     */
    int mSelectionRightPadding = 0;


    /**
     * The selection's bottom padding
     */
    int mSelectionBottomPadding = 0;


    /**
     * This view's padding
     */
    Rect mListPadding = new Rect();

以上属性表示Padding



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值