本文整理汇总了Java中android.support.design.widget.FloatingActionButton.setImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingActionButton.setImageDrawable方法的具体用法?Java FloatingActionButton.setImageDrawable怎么用?Java FloatingActionButton.setImageDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.FloatingActionButton
的用法示例。
在下文中一共展示了FloatingActionButton.setImageDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setupFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void setupFab() {
// Set up the client's FAB
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setImageDrawable(fabDrawable);
if (Utils.hasLollipop()) {
fab.setImageTintList(fabDrawableTint);
}
if (fabBackgroundTint != null) {
fab.setBackgroundTintList(fabBackgroundTint);
}
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isAnimating) return;
if (isMenuOpen()) {
closeMenu();
} else {
openMenu();
}
}
});
}
示例3: 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();
}
}
示例4: onCreate
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.named_list);
realm = Realm.getDefaultInstance();
RecyclerView namedView = (RecyclerView) findViewById(R.id.named_list_view);
namedView.setLayoutManager(new LinearLayoutManager(this));
namedView.setAdapter(getViewAdapter());
FloatingActionButton addButton = (FloatingActionButton) findViewById(R.id.add_button);
addButton.setImageDrawable(MaterialDrawableBuilder.with(this)
.setIcon(MaterialDrawableBuilder.IconValue.PLUS)
.setColorResource(R.color.text_light)
.build()
);
}
示例5: onCreate
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
viewModel = ViewModelProviders.of(this).get(CartViewModel.class);
fab = (FloatingActionButton) findViewById(R.id.fab);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setupToolbar();
handleDeepLink();
fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_share_white_24dp, null));
fab.setOnClickListener(view -> {
String cartId = viewModel.getCartId().getValue();
ShareCompat.IntentBuilder.from(this)
.setText(String.format(Locale.US, "Check out my shopping cart now using Android Instant Apps! \n%s/cart/%s", ROOT_ENDPOINT, cartId))
.setType("text/plain")
.setChooserTitle(share_cart)
.startChooser();
});
}
示例6: onCreate
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_detail);
viewModel = ViewModelProviders.of(this).get(ItemDetailViewModel.class);
viewModel.getCartId().observe(this, this::updatedCartId);
fab = (FloatingActionButton) findViewById(R.id.fab);
toolbar = (Toolbar) findViewById(R.id.toolbar);
handleDeepLink();
setupToolbar();
fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_add_shopping_cart_white_24dp, null));
fab.setOnClickListener(this::addToCart);
}
示例7: createFabMenuItem
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private View createFabMenuItem(MenuItem menuItem) {
ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
.inflate(getMenuItemLayoutId(), this, false);
FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);
fabMenuItemMap.put(miniFab, menuItem);
cardViewMenuItemMap.put(cardView, menuItem);
miniFab.setImageDrawable(menuItem.getIcon());
miniFab.setOnClickListener(this);
cardView.setOnClickListener(this);
ViewCompat.setAlpha(miniFab, 0f);
ViewCompat.setAlpha(cardView, 0f);
final CharSequence title = menuItem.getTitle();
if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
//cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
titleView.setText(title);
titleView.setTypeface(null, Typeface.BOLD);
titleView.setTextColor(miniFabTitleTextColor);
} else {
fabMenuItem.removeView(cardView);
}
miniFab.setBackgroundTintList(miniFabBackgroundTint);
if (Utils.hasLollipop()) {
miniFab.setImageTintList(miniFabDrawableTint);
}
return fabMenuItem;
}
示例8: setupFloatingButton
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void setupFloatingButton(@IdRes int id, IconValue value, View.OnClickListener listener) {
FloatingActionButton button = (FloatingActionButton) findViewById(id);
button.setImageDrawable(
MaterialDrawableBuilder.with(this)
.setIcon(value)
.setColorResource(R.color.text_light)
.build()
);
button.setOnClickListener(listener);
}
示例9: setBaseViews
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void setBaseViews(Context context){
mBackgroundView = new View(context);
mBackgroundView.setBackgroundColor(mBackgroundColor);
mBackgroundView.setAlpha(0);
addView(mBackgroundView);
mFloatingActionButton = new FloatingActionButton(context);
mFloatingActionButton.setBackgroundTintList(mFabColor);
mFloatingActionButton.setImageDrawable(mFabIcon);
addView(mFloatingActionButton);
}
示例10: resetFloatingButton
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void resetFloatingButton(FloatingActionButton actionButton) {
actionButton.setVisibility(View.GONE);
actionButton.setImageDrawable(null);
actionButton.setOnClickListener(null);
}
示例11: updateFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
* Update FAB's look and action
*/
public static void updateFab(FragmentActivity activity, String fragmentTag, int selectionCount) {
FloatingActionButton fab = (FloatingActionButton) activity.findViewById(R.id.fab);
if (fab == null) {
return;
}
Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag(fragmentTag);
if (fragment == null) {
fab.hide();
return;
}
/* Hide FAB if there are selected notes. */
if (selectionCount > 0) {
fab.hide();
return;
}
if (fragment instanceof Fab) {
final Runnable fabAction = ((Fab) fragment).getFabAction();
ActivityUtils.FragmentResources resources = new ActivityUtils.FragmentResources(activity, fragmentTag);
if (resources.fabDrawable != null && fabAction != null) {
fab.show();
fab.setBackgroundTintList(ColorStateList.valueOf(resources.actionColor));
fab.setImageDrawable(resources.fabDrawable);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fabAction.run();
}
});
} else {
fab.hide();
}
} else {
fab.hide();
}
}
示例12: AudioPlayerUI
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public AudioPlayerUI(MapsActivity mapsActivity, Game excursion)
{
this.excursion = excursion;
_context = mapsActivity;
pause = (FloatingActionButton) mapsActivity.findViewById(R.id.button_pause);
activity = mapsActivity;
//seekBar = (SeekBar) mapsActivity.findViewById(R.id.seekBar);
color = ContextCompat.getColor(_context, R.color.blue_light);
//setAudioPlayerSeekBar();
stateListener = new IObserver<PlayerState>() {
@Override
public void notify(PlayerState state) {
if (state == PlayerState.Paused || state == PlayerState.PlaybackCompleted) {
pause.setImageDrawable(ContextCompat.getDrawable(_context, android.R.drawable.ic_media_play));
}
if (state == PlayerState.Playing) {
pause.setImageDrawable(ContextCompat.getDrawable(_context, android.R.drawable.ic_media_pause));
}
}
};
trackNameListener = new IObserver<String>() {
@Override
public void notify(String trackName) {
String caption = changeAndGetTrackCaption(trackName);
if (trackName == "")
return;
Intent startingIntent = new Intent(_context, AudioService.class);
startingIntent.putExtra(AudioService.Command, AudioServiceCommand.StartForeground);
startingIntent.putExtra(AudioService.TrackCaption, caption);
startingIntent.putExtra(IntentNames.SELECTED_GAME, AudioPlayerUI.this.excursion);
_context.startService(startingIntent);
}
};
AudioService.State.subscribe(stateListener);
stateListener.notify(AudioService.getCurrentState());
positionListener = new IObserver<Integer>() {
@Override
public void notify(Integer progress) {
//seekBar.setProgress(progress);
}
};
AudioService.Position.subscribe(positionListener);
positionListener.notify(AudioService.getCurrentPosition());
AudioService.TrackName.subscribe(trackNameListener);
}
示例13: handleOrcStatusChangedEvent
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void handleOrcStatusChangedEvent(OcrStatusChangedEvent statusChangedEvent) {
Log.d(TAG, "onStatusChanged: status=" + statusChangedEvent);
Status newStatus = statusChangedEvent.getNewStatus();
boolean shouldAnimate = true;
mStatusText.setText(newStatus.getDescription());
int nextIcon = 0;
View.OnClickListener clickListener = null;
if (statusChangedEvent.isStoppingEvent()) {
Log.d(TAG, "handleOrcStatusChangedEvent: isStoppingEvent");
mDetectingRedDot.setVisibility(View.INVISIBLE);
mDetectingRedDot.clearAnimation();
nextIcon = R.drawable.ic_filter_center_focus_white_24dp;
clickListener = mScanPresenter.getStartProcessorClickListener();
} else if (statusChangedEvent.isStartingEvent()) {
Log.d(TAG, "handleOrcStatusChangedEvent: isStartingEvent");
mDetectingRedDot.setAlpha(1.0f);
mDetectingRedDot.startAnimation(mBlinkAnimation);
nextIcon = R.drawable.ic_stop_white_24dp;
clickListener = mScanPresenter.getStopProcessorClickListener();
} else if (newStatus == Status.LOADING) {
Log.d(TAG, "handleOrcStatusChangedEvent: LOADING");
nextIcon = R.drawable.ic_clear_white_24dp;
clickListener = mScanPresenter.getStopLoadingPreviewClickListener();
shouldAnimate = false;
}
if (nextIcon != 0) {
final int finalNextIcon = nextIcon;
FloatingActionButton.OnVisibilityChangedListener listener = new FloatingActionButton
.OnVisibilityChangedListener() {
@Override
public void onHidden(final FloatingActionButton fab) {
super.onHidden(fab);
fab.setImageDrawable(ContextCompat.getDrawable(getContext(), finalNextIcon));
fab.show();
}
};
if (clickListener != null) {
mFab.setOnClickListener(clickListener);
}
if (mFab.isShown() && shouldAnimate) {
mFab.hide(listener);
} else {
listener.onHidden(mFab);
}
}
}
示例14: onAttachedToWindow
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
LayoutParams layoutParams =
new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
} else {
layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
}
menuItemsLayout.setLayoutParams(layoutParams);
// Set up the client's FAB
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setImageDrawable(fabDrawable);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fab.setImageTintList(fabDrawableTint);
}
if (fabBackgroundTint != null) {
fab.setBackgroundTintList(fabBackgroundTint);
}
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isAnimating) return;
if (isMenuOpen()) {
closeMenu();
} else {
openMenu();
}
}
});
// Needed in order to intercept key events
setFocusableInTouchMode(true);
if (useTouchGuard) {
ViewParent parent = getParent();
touchGuard = new View(getContext());
touchGuard.setOnClickListener(this);
touchGuard.setWillNotDraw(true);
touchGuard.setVisibility(GONE);
if (touchGuardDrawable != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
touchGuard.setBackground(touchGuardDrawable);
} else {
touchGuard.setBackgroundDrawable(touchGuardDrawable);
}
}
if (parent instanceof FrameLayout) {
FrameLayout frameLayout = (FrameLayout) parent;
frameLayout.addView(touchGuard);
bringToFront();
} else if (parent instanceof CoordinatorLayout) {
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
coordinatorLayout.addView(touchGuard);
bringToFront();
} else if (parent instanceof RelativeLayout) {
RelativeLayout relativeLayout = (RelativeLayout) parent;
relativeLayout.addView(touchGuard,
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
bringToFront();
} else {
Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
}
}
setOnClickListener(this);
if (shouldOpenMenu)
openMenu();
}
示例15: createFabMenuItem
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private View createFabMenuItem(MenuItem menuItem) {
ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
.inflate(getMenuItemLayoutId(), this, false);
FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);
fabMenuItemMap.put(miniFab, menuItem);
cardViewMenuItemMap.put(cardView, menuItem);
miniFab.setImageDrawable(menuItem.getIcon());
miniFab.setOnClickListener(this);
cardView.setOnClickListener(this);
ViewCompat.setAlpha(miniFab, 0f);
ViewCompat.setAlpha(cardView, 0f);
final CharSequence title = menuItem.getTitle();
if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
titleView.setText(title);
titleView.setTypeface(null, Typeface.BOLD);
titleView.setTextColor(miniFabTitleTextColor);
if (miniFabTitleTextColorArray != null) {
titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
miniFabTitleTextColorArray[menuItem.getOrder()]));
}
} else {
fabMenuItem.removeView(cardView);
}
miniFab.setBackgroundTintList(miniFabBackgroundTint);
if (miniFabBackgroundTintArray != null) {
miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
miniFabBackgroundTintArray[menuItem.getOrder()]));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
miniFab.setImageTintList(miniFabDrawableTint);
}
return fabMenuItem;
}