当前位置: 首页>>代码示例>>Java>>正文


Java StateListDrawable.setState方法代码示例

本文整理汇总了Java中android.graphics.drawable.StateListDrawable.setState方法的典型用法代码示例。如果您正苦于以下问题:Java StateListDrawable.setState方法的具体用法?Java StateListDrawable.setState怎么用?Java StateListDrawable.setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.StateListDrawable的用法示例。


在下文中一共展示了StateListDrawable.setState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActionUp

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
    if (mUsingStyle) {
        mBackgroundDrawable = getBackground();
    }

    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[]{});
    } else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[]{});
        ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
        ripple.setVisible(true, true);
    }
    setPressed(false);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:Label.java

示例2: onActionDown

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
    void onActionDown() {
        if (mUsingStyle) {
            mBackgroundDrawable = getBackground();
        }

        if (mBackgroundDrawable instanceof StateListDrawable) {
            StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
            drawable.setState(new int[]{android.R.attr.state_pressed});
        } else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
            RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
            ripple.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
            ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
            ripple.setVisible(true, true);
        }
//        setPressed(true);
    }
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:18,代码来源:Label.java

示例3: onActionUp

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
    void onActionUp() {
        if (mUsingStyle) {
            mBackgroundDrawable = getBackground();
        }

        if (mBackgroundDrawable instanceof StateListDrawable) {
            StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
            drawable.setState(new int[]{});
        } else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
            RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
            ripple.setState(new int[]{});
            ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
            ripple.setVisible(true, true);
        }
//        setPressed(false);
    }
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:18,代码来源:Label.java

示例4: onActionUp

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[]{android.R.attr.state_enabled});
    } else if (Util.hasLollipop()) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[]{android.R.attr.state_enabled});
        ripple.setHotspot(calculateCenterX(), calculateCenterY());
        ripple.setVisible(true, true);
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:13,代码来源:FloatingActionButton.java

示例5: onActionDown

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
    } else if (Util.hasLollipop()) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
        ripple.setHotspot(calculateCenterX(), calculateCenterY());
        ripple.setVisible(true, true);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:13,代码来源:FloatingActionButton.java

示例6: testCreateStateList

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
/**
 * Tests the {@link Coloring#createStateList(Context, int, int, int, boolean, int)} method.
 * <p>
 * Unfortunately {@link StateListDrawable#getCurrent()} is not shadowed by Robolectric yet.
 */
@Test
public final void testCreateStateList() {
    final int colorNormal = Color.WHITE;
    final int colorActive = Color.GRAY;
    final int colorFocused = Color.YELLOW;
    final StateListDrawable drawable = Coloring.createStateList(mActivityContext, colorNormal, colorActive, colorFocused, true, 0);
    assertNotNull("StateListDrawable is null", drawable);
    drawable.setState(new int[] {});
    assertTrue("StateListDrawable is not stateful", drawable.isStateful());
    final Drawable.ConstantState constantState = drawable.getConstantState();
    assertNotNull("Constant state is null", constantState);
    final Drawable currentState = drawable.getCurrent();
    assertNull("Robolectric started shadowing current state", currentState);
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:20,代码来源:ColoringTest.java

示例7: setBookMarkIcon

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
private void setBookMarkIcon(MenuItem item) {
    TypedValue typedvalueattr = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.menuBookmarkIcon, typedvalueattr, true);
    StateListDrawable stateListDrawable = (StateListDrawable) getResources().getDrawable(typedvalueattr.resourceId);
    int[] state = {item.isChecked() ? android.R.attr.state_checked : -android.R.attr.state_checked};
    stateListDrawable.setState(state);
    item.setIcon(stateListDrawable.getCurrent());
    item.setTitle(item.isChecked() ? R.string.action_remove_book_mark : R.string.action_add_book_mark);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:10,代码来源:BookPageFragment.java

示例8: setState

import android.graphics.drawable.StateListDrawable; //导入方法依赖的package包/类
public void setState(int [] state) {
    if (mDrawable instanceof StateListDrawable) {
        StateListDrawable d = (StateListDrawable) mDrawable;
        d.setState(state);
    }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:7,代码来源:TargetDrawable.java


注:本文中的android.graphics.drawable.StateListDrawable.setState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。