當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageButton.setImageBitmap方法代碼示例

本文整理匯總了Java中android.widget.ImageButton.setImageBitmap方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageButton.setImageBitmap方法的具體用法?Java ImageButton.setImageBitmap怎麽用?Java ImageButton.setImageBitmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageButton的用法示例。


在下文中一共展示了ImageButton.setImageBitmap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPanel

import android.widget.ImageButton; //導入方法依賴的package包/類
private ViewGroup getPanel(Context context, int type) {
    final ViewGroup mViewGroup = new LinearLayout(context);
    LinearLayout.LayoutParams btnParam =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    //   btnParam.weight = 1;
    btnParam.gravity = Gravity.CENTER_VERTICAL;
    LinearLayout.LayoutParams seekBarParam =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    seekBarParam.weight = 1;
    seekBarParam.gravity = Gravity.CENTER;

    ImageButton btnBack = new ImageButton(context);
    btnBack.setImageBitmap(backBitmap);
    btnBack.setScaleType(ImageView.ScaleType.FIT_CENTER);
    btnBack.setBackgroundColor(Color.alpha(255));

    SeekBar seekBar = getSeekBar(context, type);

    ImageButton btnFunc = new ImageButton(context);
    btnFunc.setImageBitmap(funcBitmap);
    btnFunc.setScaleType(ImageView.ScaleType.FIT_CENTER);
    btnFunc.setBackgroundColor(Color.alpha(255));

    mViewGroup.addView(btnBack, btnParam);
    mViewGroup.addView(seekBar, seekBarParam);
    mViewGroup.addView(btnFunc, btnParam);

    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mViewGroup.setBackgroundColor(Color.BLACK);
    btnBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            wm.removeView(mViewGroup);
        }
    });

    return mViewGroup;
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:39,代碼來源:LightAndVolumeController.java

示例2: initHomeNavbar

import android.widget.ImageButton; //導入方法依賴的package包/類
private static void initHomeNavbar(LinearLayout homeNavbar, final ViewPager vp) {
    XpLog.i("initHomeNavbar");
    Context context = homeNavbar.getContext();

    ImageButton btnCall = new ImageButton(context);
    btnCall.setImageBitmap(ImageUtil.byte2Bitmap(DataHook.mapImgRes.get(ConstantStr.FUNC_SMALL_POINT_CODE)));
    btnCall.setScaleType(ImageView.ScaleType.FIT_CENTER);
    btnCall.setBackgroundColor(Color.alpha(255));
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    homeNavbar.addView(btnCall, params);

    setHomePointPosition(homeNavbar);

    btnCall.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            vp.setCurrentItem(2);
        }
    });
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:22,代碼來源:NavBarHook.java

示例3: buildBottomBarButton

import android.widget.ImageButton; //導入方法依賴的package包/類
/**
 * Builds an {@link ImageButton} from the data in this params. Generated buttons should be
 * placed on the bottom bar. The button's tag will be its id.
 * @param parent The parent that the inflated {@link ImageButton}.
 * @param listener {@link OnClickListener} that should be used with the button.
 * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid.
 */
ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) {
    if (mIsOnToolbar) return null;

    ImageButton button = (ImageButton) LayoutInflater.from(context)
            .inflate(R.layout.custom_tabs_bottombar_item, parent, false);
    button.setId(mId);
    button.setImageBitmap(mIcon);
    button.setContentDescription(mDescription);
    if (mPendingIntent == null) {
        button.setEnabled(false);
    } else {
        button.setOnClickListener(listener);
    }
    button.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            final int screenWidth = view.getResources().getDisplayMetrics().widthPixels;
            final int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
            final int[] screenPos = new int[2];
            view.getLocationOnScreen(screenPos);
            final int width = view.getWidth();

            Toast toast = Toast.makeText(
                    view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.BOTTOM | Gravity.END,
                    screenWidth - screenPos[0] - width / 2,
                    screenHeight - screenPos[1]);
            toast.show();
            return true;
        }
    });
    return button;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:41,代碼來源:CustomButtonParams.java


注:本文中的android.widget.ImageButton.setImageBitmap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。