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


Java ImageButton.setBackgroundColor方法代碼示例

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


在下文中一共展示了ImageButton.setBackgroundColor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onCreateViewHolder

import android.widget.ImageButton; //導入方法依賴的package包/類
View onCreateViewHolder(ViewGroup parent, int viewType){
    if(viewType == ITEM_EMOJ){
        ImageButton imageView = new ImageButton(context);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(EmojiUtil.dip2px(context,40),
                ViewGroup.LayoutParams.MATCH_PARENT));
        imageView.setBackgroundColor(Color.WHITE);
        return imageView;
    }else {
        View view = (View) styleWrapperManager.bottomTypeViews.get(viewType-ITEM_VIEW);
        view.setLayoutParams(new ViewGroup.LayoutParams(EmojiUtil.dip2px(context,40),
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setBackgroundColor(Color.WHITE);
        return view;
    }
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:16,代碼來源:BottomStyleManager.java

示例4: initMainLeftViews

import android.widget.ImageButton; //導入方法依賴的package包/類
/**
 * 初始化主視圖左邊部分
 *
 * @param context
 */
private void initMainLeftViews(Context context) {
    LayoutParams leftInnerParams = new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    leftInnerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    leftInnerParams.addRule(RelativeLayout.CENTER_VERTICAL);

    if (leftType == TYPE_LEFT_TEXTVIEW) {
        // 初始化左邊TextView
        tvLeft = new TextView(context);
        tvLeft.setId(ViewFinder.generateViewId());
        tvLeft.setText(leftText);
        tvLeft.setTextColor(leftTextColor);
        tvLeft.setTextSize(TypedValue.COMPLEX_UNIT_PX, leftTextSize);
        tvLeft.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        tvLeft.setSingleLine(true);
        tvLeft.setOnClickListener(this);
        // 設置DrawableLeft及DrawablePadding
        if (leftDrawable != 0) {
            tvLeft.setCompoundDrawablePadding((int) leftDrawablePadding);
            if (SysUtils.hasJellyBeanMr1()) {
                tvLeft.setCompoundDrawablesRelativeWithIntrinsicBounds(leftDrawable, 0, 0, 0);
            } else {
                tvLeft.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, 0, 0, 0);
            }
            tvLeft.setPadding(0, 0, PADDING_5, 0);
        } else {
            tvLeft.setPadding(PADDING_5, 0, PADDING_5, 0);
        }

        rlMain.addView(tvLeft, leftInnerParams);
        mFadeViewList.add(tvLeft);
    } else if (leftType == TYPE_LEFT_IMAGEBUTTON) {
        // 初始化左邊ImageButton
        btnLeft = new ImageButton(context);
        btnLeft.setId(ViewFinder.generateViewId());
        btnLeft.setBackgroundColor(Color.TRANSPARENT);
        btnLeft.setImageResource(leftImageResource);
        btnLeft.setPadding(PADDING_12, 0, PADDING_12, 0);
        btnLeft.setOnClickListener(this);

        rlMain.addView(btnLeft, leftInnerParams);
        mFadeViewList.add(btnLeft);
    } else if (leftType == TYPE_LEFT_CUSTOM_VIEW) {
        // 初始化自定義View
        viewCustomLeft = LayoutInflater.from(context).inflate(leftCustomViewRes, null);
        if (viewCustomLeft.getId() == 0) {
            viewCustomLeft.setId(ViewFinder.generateViewId());
        }
        rlMain.addView(viewCustomLeft, leftInnerParams);
        mFadeViewList.add(viewCustomLeft);
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:57,代碼來源:CommonTitleBar.java

示例5: initMainRightViews

import android.widget.ImageButton; //導入方法依賴的package包/類
/**
 * 初始化主視圖右邊部分
 *
 * @param context
 */
private void initMainRightViews(Context context) {
    LayoutParams rightInnerParams = new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    rightInnerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rightInnerParams.addRule(RelativeLayout.CENTER_VERTICAL);

    if (rightType == TYPE_RIGHT_TEXTVIEW) {
        // 初始化右邊TextView
        tvRight = new TextView(context);
        tvRight.setId(ViewFinder.generateViewId());
        tvRight.setText(rightText);
        tvRight.setTextColor(rightTextColor);
        tvRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, rightTextSize);
        tvRight.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        tvRight.setSingleLine(true);
        tvRight.setPadding(PADDING_15, 0, PADDING_15, 0);
        tvRight.setOnClickListener(this);
        rlMain.addView(tvRight, rightInnerParams);
        mFadeViewList.add(tvRight);
    } else if (rightType == TYPE_RIGHT_IMAGEBUTTON) {
        // 初始化右邊ImageBtn
        btnRight = new ImageButton(context);
        btnRight.setId(ViewFinder.generateViewId());
        btnRight.setImageResource(rightImageResource);
        btnRight.setBackgroundColor(Color.TRANSPARENT);
        btnRight.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        btnRight.setPadding(PADDING_15, 0, PADDING_15, 0);
        btnRight.setOnClickListener(this);
        rlMain.addView(btnRight, rightInnerParams);
        mFadeViewList.add(btnRight);
    } else if (rightType == TYPE_RIGHT_CUSTOM_VIEW) {
        // 初始化自定義view
        viewCustomRight = LayoutInflater.from(context).inflate(rightCustomViewRes, null);
        if (viewCustomRight.getId() == 0) {
            viewCustomRight.setId(ViewFinder.generateViewId());
        }
        rlMain.addView(viewCustomRight, rightInnerParams);

        mFadeViewList.add(viewCustomRight);
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:46,代碼來源:CommonTitleBar.java


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