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


Java ImageButton.setLayoutParams方法代码示例

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


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

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

示例2: setupSearchOptions

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void setupSearchOptions(SearchView searchView) {
    final ImageButton searchOptionsButton =
            (ImageButton) getActivity().getLayoutInflater().inflate(R.layout.search_view_options_button, null);
    LinearLayout searchViewSearchPlate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    searchViewSearchPlate.addView(searchOptionsButton);
    searchOptionsButton.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
    searchOptionsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onSearchOptionsButtonClicked();
        }
    });
}
 
开发者ID:graviton57,项目名称:TheNounProject,代码行数:17,代码来源:SearchIconFragment.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: getMenuItemView

import android.widget.ImageButton; //导入方法依赖的package包/类
private View getMenuItemView(MenuItem item) {
  final ImageButton button = new ImageButton(context);
  button.setImageDrawable(item.getIcon());
  button.setBackgroundResource(R.drawable.toolbar_button);
  button.setId(item.getItemId());
  button.setLayoutParams(new LayoutParams(itemWidth,
      ViewGroup.LayoutParams.MATCH_PARENT));
  button.setOnClickListener(this);
  button.setOnLongClickListener(this);
  return button;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:12,代码来源:AyahToolBar.java

示例5: onCreate

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    estado = Estado.NAO_VIRADA;
    grid = (GridLayout) findViewById(R.id.grid);
    grid.setColumnCount(4);

    final int NUMBER_OF_CARDS = this.resources.length * 2;

    cards = new ArrayList<>(NUMBER_OF_CARDS);

    for (int i = 0; i < NUMBER_OF_CARDS; i++) {
        ImageButton btn = new ImageButton(this);
        btn.setImageResource(R.mipmap.ic_costas);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(150, 150);
        btn.setLayoutParams(layoutParams);
        btn.setOnClickListener(this);
        btn.setTag(new CardInfo(resources[i % 8]));
        cards.add(btn);
    }

    Collections.shuffle(cards);

    for(ImageButton button : this.cards ){
        grid.addView(button);
    }
}
 
开发者ID:Mr-Holmes,项目名称:Jogo-da-Memoria,代码行数:33,代码来源:Game.java

示例6: InfoBarLayout

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:66,代码来源:InfoBarLayout.java

示例7: addButton

import android.widget.ImageButton; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void addButton(@NonNull final Button button, @NonNull final ActionListener thisListener)
{
	// interface button to implementation
	final String name = button.name();
	final ButtonImplementation impl = ButtonImplementation.valueOf(name);

	// new button
	final ImageButton imageButton = new ImageButton(getContext());
	imageButton.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

	// drawable
	final int thisIconIndex = impl.getIconIndex();
	final Drawable bitmapDrawable = this.drawables[thisIconIndex];

	// tint drawable
	Utils.tint(bitmapDrawable, this.iconTint);

	// button drawable
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
	{
		imageButton.setBackground(bitmapDrawable);
	}
	else
	{
		imageButton.setBackgroundDrawable(bitmapDrawable);
	}

	// listener
	imageButton.setOnClickListener(thisListener::onAction);

	// add
	this.panel.addView(imageButton, this.layoutParams);
}
 
开发者ID:1313ou,项目名称:TreebolicLib,代码行数:36,代码来源:Toolbar.java

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

示例9: setSizeMainElems

import android.widget.ImageButton; //导入方法依赖的package包/类
public void setSizeMainElems(ImageButton imageButton, int scale) {
    ViewGroup.LayoutParams params = imageButton.getLayoutParams();
    params.width = (int) (scale / 2.4);
    params.height = scale;
    imageButton.setLayoutParams(params);
}
 
开发者ID:Existentio,项目名称:OddLauncher,代码行数:7,代码来源:SettingsHelper.java


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