本文整理汇总了Java中android.support.design.widget.FloatingActionButton.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingActionButton.getDrawable方法的具体用法?Java FloatingActionButton.getDrawable怎么用?Java FloatingActionButton.getDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.FloatingActionButton
的用法示例。
在下文中一共展示了FloatingActionButton.getDrawable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void init(Context context){
actionButton=new FloatingActionButton(context);
toolbarLayout=new LinearLayout(getContext());
float density = getResources().getDisplayMetrics().density;
addView(actionButton,(int)(56*density),(int)(56*density));
FrameLayout.LayoutParams params=
FrameLayout.LayoutParams.class.cast(actionButton.getLayoutParams());
params.gravity= Gravity.CENTER;
actionButton.setLayoutParams(params);
toolbarLayout.setGravity(Gravity.CENTER);
actionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onButtonClick();
}
});
fabDrawable=actionButton.getDrawable();
if(fabDrawable!=null) actionButton.setImageDrawable(fabDrawable);
setToolbarColor(-1);
}
示例2: setOrAnimatePlusCheckIcon
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public void setOrAnimatePlusCheckIcon(final FloatingActionButton fab, boolean isCheck,
boolean allowAnimate) {
if (!hasL()) {
compatSetOrAnimatePlusCheckIcon(fab, isCheck, allowAnimate);
return;
}
Drawable drawable = fab.getDrawable();
if (!(drawable instanceof AnimatedStateListDrawable)) {
Resources res = mActivity.getResources();
drawable = res.getDrawable(R.drawable.add_schedule_fab_icon_anim);
drawable.setTint(res.getColor(R.color.fab_icon_color));
fab.setImageDrawable(drawable);
}
if (allowAnimate) {
drawable.setState(isCheck ? STATE_UNCHECKED : STATE_CHECKED);
drawable.jumpToCurrentState();
drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
} else {
drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
drawable.jumpToCurrentState();
}
}
示例3: fabClicked
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public void fabClicked(View v) {
if (v instanceof FloatingActionButton) {
FloatingActionButton fab = (FloatingActionButton) v;
Drawable drawable = fab.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent();
i.setAction(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
} else {
Toast.makeText(MainActivity.this, getString(R.string.error), Toast.LENGTH_SHORT).show();
}
}
}, (int) (500 * Util.getAnimatorSpeed(this)));
}