android.graphics.drawable.Drawable#getLevel()源码实例Demo

下面列出了android.graphics.drawable.Drawable#getLevel() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DropDownMenu   文件: FixedTabIndicator.java
private void switchTab(int pos) {
    TextView tv = getChildAtCurPos(pos);

    Drawable drawable = tv.getCompoundDrawables()[2];
    int level = drawable.getLevel();

    if (mOnItemClickListener != null) {
        mOnItemClickListener.onItemClick(tv, pos, level == 1);
    }

    if (mLastIndicatorPosition == pos) {
        // 点击同一个条目时
        tv.setTextColor(level == 0 ? mTabSelectedColor : mTabDefaultColor);
        drawable.setLevel(1 - level);

        return;
    }

    mCurrentIndicatorPosition = pos;
    resetPos(mLastIndicatorPosition);

    //highLightPos(pos);
    tv.setTextColor(mTabSelectedColor);
    tv.getCompoundDrawables()[2].setLevel(1);

    mLastIndicatorPosition = pos;
}
 
源代码2 项目: material-drawer   文件: DrawerView.java
@Override
public Integer get(Drawable object) {
    return object.getLevel();
}