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