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