本文整理了Java中android.widget.ImageButton.setLayoutParams()
方法的一些代码示例,展示了ImageButton.setLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.setLayoutParams()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:setLayoutParams
暂无
代码示例来源:origin: Clans/FloatingActionButton
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
if (params instanceof ViewGroup.MarginLayoutParams && mUsingElevationCompat) {
((ViewGroup.MarginLayoutParams) params).leftMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).topMargin += getShadowY();
((ViewGroup.MarginLayoutParams) params).rightMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).bottomMargin += getShadowY();
}
super.setLayoutParams(params);
}
代码示例来源:origin: nickbutcher/plaid
fab.setLayoutParams(lpFab);
代码示例来源:origin: stackoverflow.com
ImageButton dot = new ImageButton(this);// since I add onClick for the dot
//setImageBitmap
dot.setVisibility(View.INVISIBLE);
RelativeLayout.LayoutParams dotparams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
dotparams.setMargins(0,0,0,0);
dot.setLayoutParams(dotparams);
final RelativeLayout myLayout = (RelativeLayout)findViewById(R.id.maplayout);//set an Id for your RelativeLayout
myLayout.addView(dot,dotparams);
代码示例来源:origin: stackoverflow.com
TextView tv = new TextView(this);
tv.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
ImageButton imb=new ImageButton(this);
imb.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
ll.addView(imb);
ll.addView(tv);
代码示例来源:origin: stackoverflow.com
Bitmap image = BitmapFactory.decodeResource(getResources(),R.drawable.testbild);
ImageButton btnMapLoc = (ImageButton) findViewById(R.id.imageButton1);
LayoutParams lp = new LayoutParams(image.getWidth(), image.getHeight());
btnMapLoc.setLayoutParams(lp);
btnMapLoc.setImageBitmap(image);
代码示例来源:origin: stackoverflow.com
ImageButton hangupButton = (ImageButton)findViewById(R.id.screen_p2pcall_hangup);
int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
(float) 120, getResources().getDisplayMetrics());
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
(float) 50, getResources().getDisplayMetrics());
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(width,height);
rlp.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
hangupButton.setLayoutParams(rlp);
hangupButton.setVisibility(RelativeLayout.VISIBLE);
代码示例来源:origin: stackoverflow.com
ImageButton ib = new ImageButton(this); //<-- this is the activity
ib.setImageResource(R.drawable.my_button_image);
ib.setLayoutParams(new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
代码示例来源:origin: stackoverflow.com
ImageButton img_bt = (ImageButton) view.findViewById(R.id.img_bt);
Display display = getActivity().getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(width/10*7, width/10*7);
img_bt.setLayoutParams(parms);
代码示例来源:origin: stackoverflow.com
ImageButton imageButton1 = (ImageButton) findViewById(R.id.imageButton1);
LinearLayout.LayoutParams layoutParams = (LayoutParams) imageButton1
.getLayoutParams();
layoutParams.setMargins(layoutParams.leftMargin,
layoutParams.topMargin, layoutParams.rightMargin,
(layoutParams.bottomMargin - 50));
imageButton1.setLayoutParams(layoutParams);
代码示例来源:origin: stackoverflow.com
public void getScreenRes(){
DisplayMetrics display = this.getResources().getDisplayMetrics();
int width = display.widthPixels;
int height = display.heightPixels;
int buttonheight = display.heightPixels / 8;
double buttonwidth = buttonheight * 2.66666667;
int buttonwidthint = (int) Math.round(buttonwidth);
ImageButton firsttimeFB = (ImageButton) findViewById(R.id.firsttime_fb);
LayoutParams lp = firsttimeFB.getLayoutParams();
lp.width = buttonwidthint;
lp.height = buttonheight;
firsttimeFB.setLayoutParams(lp);
代码示例来源:origin: stackoverflow.com
ImageButton imgBtn = (ImageButton)findViewById(R.id.img_btn);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imgBtn.getLayoutParams();
params.setMargins(0, 0, 0, 25); //bottom margin is 25 here (change it as u wish)
imgBtn.setLayoutParams(params);
代码示例来源:origin: stackoverflow.com
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageButton image;
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.grid__item, null);
}
image = (ImageButton) convertView.findViewById(R.id.image);
image.setImageResource(Constantes.HIDECARD_RESOURCE);
image.setLayoutParams(new GridView.LayoutParams(130, 130));
image.setBackgroundColor(Color.TRANSPARENT);
return convertView;
}
代码示例来源:origin: stackoverflow.com
private View createImageButton(int x, int y) {
ImageButton button = new ImageButton(context);
// Adjust button size (?)
button.setLayoutParams(new TableRow.LayoutParams(myImage.getMinimumWidth(),
myImage.getMinimumHeight(), 1f));
//It doesn't work at all
button.setBackground(myImage);
button.setScaleType(ScaleType.FIT_XY)
...
return button;
}
代码示例来源:origin: stackoverflow.com
ImageButton shareButton = new ImageButton(this);
shareButton.setBackgroundResource(android.R.drawable.ic_menu_share);
RelativeLayout.LayoutParams shareParams = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
shareParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, navigationLogo.getId());
shareParams.width = INTEGER_NUMBER;
shareButton.setLayoutParams(shareParams);
代码示例来源:origin: stackoverflow.com
ImageButton mImageButton = new ImageButton(context);
mImageButton.setImageResource(R.drawable.close_button);
RelativeLayout.LayoutParams paramsB = new RelativeLayout.LayoutParams(width, height);
paramsB.addRule(RelativeLayout.ALIGN_PARENT_TOP);
paramsB.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
mImageButton.setLayoutParams(paramsB);
mImageButton.setAdjustViewBounds(true);
mImageButton.setBackgroundDrawable(null);
mRelativeLayout.addView(mImageButton);
mImageButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
代码示例来源:origin: stackoverflow.com
LinearLayout ll = (LinearLayout)findViewById(R.id.linearLayout2);
ImageButton b = new ImageButton(this);
b.setText("ImageButton");
b.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
b.setId(MY_BUTTON);
i1Btn = R.drawable.image_name;
i1.setImageResource(i1Btn);
b.setOnClickListener(this);
ll.addView(b);
代码示例来源:origin: stackoverflow.com
private void addImageButton(RelativeLayout mainLayout, int x, int y, int width, int height, OnClickListener onClickListener){
ImageButton imageButton = new ImageButton(this);
imageButton.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.height = height;
params.width = width;
imageButton.setLayoutParams(params);
imageButton.setScaleType(ImageView.ScaleType.FIT_XY);
imageButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher));
params.leftMargin = x - width/2;
params.topMargin = y - height/2;
imageButton.setOnClickListener(onClickListener);
mainLayout.addView(imageButton);
}
代码示例来源:origin: stackoverflow.com
private void setupBalloon(ImageButton b, int i) {
int imageId = (int)(Math.random() * images.length);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
b.setLayoutParams(params);
b.setImageResource(images[imageId]);
b.setBackgroundColor(Color.TRANSPARENT);
b.setScaleX(0.4f);
b.setScaleY(0.4f);
b.setX((float) (Math.random() * (width - b.getWidth())));
b.setY((float) (Math.random() * (height - b.getHeight())));
b.setVisibility(View.VISIBLE);
}
代码示例来源:origin: Blankeer/MDWechat
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
if (params instanceof ViewGroup.MarginLayoutParams && mUsingElevationCompat) {
((ViewGroup.MarginLayoutParams) params).leftMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).topMargin += getShadowY();
((ViewGroup.MarginLayoutParams) params).rightMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).bottomMargin += getShadowY();
}
super.setLayoutParams(params);
}
代码示例来源:origin: douzifly/clear-todolist
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
if (params instanceof ViewGroup.MarginLayoutParams && mUsingElevationCompat) {
((ViewGroup.MarginLayoutParams) params).leftMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).topMargin += getShadowY();
((ViewGroup.MarginLayoutParams) params).rightMargin += getShadowX();
((ViewGroup.MarginLayoutParams) params).bottomMargin += getShadowY();
}
super.setLayoutParams(params);
}
内容来源于网络,如有侵权,请联系作者删除!