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


Java FloatingActionButton.setImageDrawable方法代码示例

本文整理汇总了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);


    }
 
开发者ID:vpaliyX,项目名称:Expandable-Action-Button,代码行数:25,代码来源:ExpandableButtonView.java

示例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();
            }
        }
    });
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:25,代码来源:FabSpeedDial.java

示例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();
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:25,代码来源:LUtils.java

示例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()
    );
}
 
开发者ID:SeriousBug,项目名称:Kutuk,代码行数:17,代码来源:NamedListActivity.java

示例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();
    });
}
 
开发者ID:willowtreeapps,项目名称:android-instant-apps-demo,代码行数:23,代码来源:CartActivity.java

示例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);
}
 
开发者ID:willowtreeapps,项目名称:android-instant-apps-demo,代码行数:17,代码来源:ItemDetailActivity.java

示例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;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:36,代码来源:FabSpeedDial.java

示例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);
}
 
开发者ID:SeriousBug,项目名称:Kutuk,代码行数:11,代码来源:ObjectDetailActivity.java

示例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);
}
 
开发者ID:chengkun123,项目名称:ReadMark,代码行数:12,代码来源:MultiFloatingActionButton.java

示例10: resetFloatingButton

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void resetFloatingButton(FloatingActionButton actionButton) {
    actionButton.setVisibility(View.GONE);
    actionButton.setImageDrawable(null);
    actionButton.setOnClickListener(null);
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:6,代码来源:BaseSecondaryFragment.java

示例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();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:49,代码来源:MainFab.java

示例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);


}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:58,代码来源:AudioPlayerUI.java

示例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);
        }
    }
}
 
开发者ID:dvdciri,项目名称:DeepImagePreview-Project,代码行数:61,代码来源:ScanFragment.java

示例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();
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:81,代码来源:FabSpeedDial.java

示例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;
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:47,代码来源:FabSpeedDial.java


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