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


Java ImageButton.setScaleType方法代码示例

本文整理汇总了Java中android.widget.ImageButton.setScaleType方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setScaleType方法的具体用法?Java ImageButton.setScaleType怎么用?Java ImageButton.setScaleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageButton的用法示例。


在下文中一共展示了ImageButton.setScaleType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onBindView

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    LinearLayout widgetFrameView = ((LinearLayout) view.findViewById(android.R.id.widget_frame));
    mBtnAppIcon = new ImageButton(mContext);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mAppIconPreviewSizePx, mAppIconPreviewSizePx);
    lp.gravity = Gravity.CENTER;
    mBtnAppIcon.setLayoutParams(lp);
    mBtnAppIcon.setScaleType(ScaleType.CENTER_CROP);
    mBtnAppIcon.setImageDrawable(mAppInfo.icon);
    mBtnAppIcon.setFocusable(false);
    if (mIconPickerEnabled) {
        mBtnAppIcon.setOnClickListener(this);
        mBtnAppIcon.setOnLongClickListener(this);
    } else {
        mBtnAppIcon.setEnabled(false);
    }
    widgetFrameView.addView(mBtnAppIcon);
    widgetFrameView.setVisibility(View.VISIBLE);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:22,代码来源:AppPickerPreference.java

示例3: 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

示例4: createView

import android.widget.ImageButton; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@NonNull
@Override
public ImageButton createView() {
    ImageButton imageViewButton = new ImageButton(getContext());
    if(!enableAutoSet) {
        //无边框的带有水波纹的按钮样式
        TypedArray typedArray = getContext().obtainStyledAttributes(new int[]{R.attr.selectableItemBackgroundBorderless});
        Drawable drawable = typedArray.getDrawable(0);
        imageViewButton.setBackgroundDrawable(drawable);
        typedArray.recycle();
    }else
        imageViewButton.setBackgroundDrawable(null);

    imageViewButton.setImageResource(idRes);
    imageViewButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    return imageViewButton;
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:19,代码来源:ImageViewButtonItem.java

示例5: instantiateItem

import android.widget.ImageButton; //导入方法依赖的package包/类
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater inflater = (LayoutInflater) QuickLaunchView.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout pageView = (LinearLayout) inflater.inflate(R.layout.shade_quick_launch_page, null);
    for (int i = position * 5; i < (position * 5) + 5; i++) {
        ImageButton button = (ImageButton) inflater.inflate(R.layout.quicklaunch_button, null);
        button.setScaleType(ScaleType.FIT_CENTER);
        if (i < this.quickLaunchApps.size()) {
            final App app = (App) this.quickLaunchApps.get(i);
            button.setImageDrawable(app.getAppIcon());
            button.setOnClickListener(new OnClickListener() {
                public void onClick(View view) {
                    ((InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class)).closeDrawer();
                    LockScreenManager lockScreenManager = (LockScreenManager) GuiceModule.get().getInstance(LockScreenManager.class);
                    if (lockScreenManager.isPhoneLocked()) {
                        lockScreenManager.unlockAndLaunchApp(app);
                    } else {
                        QuickLaunchView.this.appManager.launchAppWithBackButton(app, AppLaunchMethod.Quicklaunch);
                    }
                }
            });
        } else {
            button.setBackground(null);
            button.setOnClickListener(null);
        }
        pageView.addView(button, new LayoutParams(-1, -1, 0.5f));
    }
    container.addView(pageView);
    return pageView;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:30,代码来源:QuickLaunchView.java

示例6: getView

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (LayoutParams.MATCH_PARENT != mWidth) {
        mKeyWidth = (mWidth - 2 * mMarginCol - mPaddingLeft
                - mPaddingRight) / 3;
    }
    mKeyHeight = (mHeight - mTitleHeight - mPaddingTop - mPaddingBottom
            - 3 * mMarginRow) / 4;
    ImageButton buttonView = new ImageButton(mContext);
    buttonView.setScaleType(ScaleType.CENTER_INSIDE);
    buttonView.setLayoutParams(
            new AbsListView.LayoutParams(mKeyWidth, mKeyHeight));

    TextView textView = new TextView(mContext);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        textView.setTextColor(
                mContext.getResources().getColor(mNumColor));
    } else {
        textView.setTextColor(mNumColor);
    }
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumSize);
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(
            new AbsListView.LayoutParams(mKeyWidth, mKeyHeight));
    if (!mIsAudio) {
        buttonView.setSoundEffectsEnabled(false);
        textView.setSoundEffectsEnabled(false);
    }

    long id = getItemId(position);
    String key = (String) getItem(position);
    if (Constant.CONFIRM_BUTTON_ITEM_ID == id) {
        if (null != mDoneForeSelector && null != mDoneBgSelector) {
            setDoneKey(buttonView);
        } else {
            setDefaultDoneDelKey(textView);
            String doneKeyStr = mContext.getResources()
                    .getString(R.string.str_done);
            textView.setText(doneKeyStr);
            int doneKeyColor = mContext.getResources()
                    .getColor(R.color.btn_security_keyboard_done);

            textView.setTextColor(doneKeyColor);
            int doneBackGroundColor = mContext.getResources()
                    .getColor(R.color.bg_security_keyboard_title);
            textView.setBackgroundColor(doneBackGroundColor);
            textView.setTextSize(16);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    } else if (Constant.DELETE_BUTTON_ITEM_ID == id) {
        if (null != mDelForeSelector || null != mDelBgSelector) {
            setDelKey(buttonView);
        } else {
            textView.setText(key);
            setDefaultDoneDelKey(textView);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    } else {
        if (null != mNumForeSelectorArray) {
            setNumberKey(buttonView, (int) id);
        } else {
            setDefaultNumKey(textView, (int) id);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    }
    buttonView.setId((int) getItemId(position));
    buttonView.setOnClickListener(onPasswordButtonClickListener);
    return buttonView;
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:77,代码来源:SafetyKeyboard.java

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