本文整理了Java中android.widget.ImageButton.getLayoutParams()
方法的一些代码示例,展示了ImageButton.getLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.getLayoutParams()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:getLayoutParams
暂无
代码示例来源:origin: nickbutcher/plaid
.getLayoutParams();
代码示例来源:origin: safetysystemtechnology/audio-recorder-button
public void unRevealSizeToRemove() {
this.mImageButton.getLayoutParams().width = ((removeImageWidth > 0) && (removeImageWidth < DEFAULT_REMOVE_ICON_SIZE)) ? removeImageWidth : DEFAULT_REMOVE_ICON_SIZE;
this.mImageButton.getLayoutParams().height = ((removeImageHeight > 0) && (removeImageHeight < DEFAULT_REMOVE_ICON_SIZE)) ? removeImageHeight : DEFAULT_REMOVE_ICON_SIZE;
this.mImageButton.requestLayout();
}
代码示例来源:origin: safetysystemtechnology/audio-recorder-button
public void changeSizeToRemove() {
if (this.mImageButton.getLayoutParams().width != this.mImageView.getWidth()) {
this.mImageButton.getLayoutParams().width = this.mImageView.getWidth();
this.mImageButton.getLayoutParams().height = this.mImageView.getHeight();
this.mImageButton.requestLayout();
this.mImageButton.setX(0);
}
}
代码示例来源: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
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
Class<?> c;
ImageButton imageButton;
AppCompatImageButton appCompatImageButton;
for (int i = 0; i < toolbar.getChildCount(); i++) {
c = toolbar.getChildAt(i).getClass();
if (c == AppCompatImageButton.class) {
appCompatImageButton = (AppCompatImageButton) toolbar.getChildAt(i);
padding -= appCompatImageButton.getWidth()*1.3;
padding -= appCompatImageButton.getPaddingLeft();
padding -= appCompatImageButton.getPaddingRight();
if (appCompatImageButton.getLayoutParams().getClass() == LinearLayout.LayoutParams.class) {
padding -= ((LinearLayout.LayoutParams) appCompatImageButton.getLayoutParams()).getMarginEnd();
padding -= ((LinearLayout.LayoutParams) appCompatImageButton.getLayoutParams()).getMarginStart();
}
break;
}
else if (c == ImageButton.class) {
imageButton = (ImageButton) toolbar.getChildAt(i);
padding -= imageButton.getWidth();
padding -= imageButton.getPaddingLeft();
padding -= imageButton.getPaddingRight();
if (imageButton.getLayoutParams().getClass() == LinearLayout.LayoutParams.class) {
padding -= ((LinearLayout.LayoutParams) imageButton.getLayoutParams()).getMarginEnd();
padding -= ((LinearLayout.LayoutParams) imageButton.getLayoutParams()).getMarginStart();
}
break;
}
}
代码示例来源:origin: Shirlman/YiPlayer
@Override
public void onClick(View v) {
View videoControllerTop = mVideoControllerRootView.findViewById(R.id.video_controller_top);
View videoControllerBottom = mVideoControllerRootView.findViewById(R.id.video_controller_bottom);
View videoControllerRight = mVideoControllerRootView.findViewById(R.id.video_controller_right);
mIsLocked = !mIsLocked;
int lockImageSize;
if(mIsLocked) {
mDefaultLockImageSize = mVideoControllerVideoLock.getWidth();
lockImageSize = (int)(mDefaultLockImageSize * 1.5);
videoControllerTop.setVisibility(View.INVISIBLE);
videoControllerBottom.setVisibility(View.INVISIBLE);
videoControllerRight.setVisibility(View.INVISIBLE);
} else {
lockImageSize = mDefaultLockImageSize;
videoControllerTop.setVisibility(View.VISIBLE);
videoControllerBottom.setVisibility(View.VISIBLE);
videoControllerRight.setVisibility(View.VISIBLE);
}
ViewGroup.LayoutParams layoutParams = mVideoControllerVideoLock.getLayoutParams();
layoutParams.width = lockImageSize;
layoutParams.height = lockImageSize;
mVideoControllerVideoLock.setLayoutParams(layoutParams);
startHideVideoControllerTimer();
}
};
代码示例来源:origin: trezor/trezor-android
@Override
public ViewHolderBase onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == R.layout.change_homescreen_item_custom_img) {
return new ViewHolderPickCustomImg(getLayoutInflater().inflate(R.layout.change_homescreen_item_custom_img, parent, false));
}
else {
ViewHolderImage ret = new ViewHolderImage((ImageButton) getLayoutInflater().inflate(R.layout.change_homescreen_item, parent, false));
ret.imageButton.getLayoutParams().width = imageWidth;
ret.imageButton.getLayoutParams().height = imageHeight;
if (isV2)
ViewUtils.setBackgroundResourceKeepPadding(ret.imageButton, R.drawable.bg_homescreen_item_v2);
return ret;
}
}
代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android
= (RelativeLayout.LayoutParams) mBtnMyLocation.getLayoutParams();
RelativeLayout.LayoutParams paramsHandle
= (RelativeLayout.LayoutParams) mBtnHandle.getLayoutParams();
if ((paramsHandle != null) && (paramsMyLocation != null)) {
if (show) {
代码示例来源:origin: GitLqr/MaterialDesignDemo
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fake_fab_interactive);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mRv = (RecyclerView) findViewById(R.id.rv);
mFab = (ImageButton) findViewById(R.id.fab);
mToolbarBottomMargin = ((ViewGroup.MarginLayoutParams) mToolbar.getLayoutParams()).bottomMargin;
mFabBottomMargin = ((ViewGroup.MarginLayoutParams) mFab.getLayoutParams()).bottomMargin;
mRv.setLayoutManager(new LinearLayoutManager(this));
mRv.setAdapter(new MyAdapter(mData));
mRv.addOnScrollListener(new FakeFabScrollListener(this));
}
代码示例来源:origin: tianzhijiexian/AppBar
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBar, defStyleAttr, 0);
final String navBtnGravity = a.getString(R.styleable.AppBar_navigationGravity);
final int[] styleableResIds = {R.styleable.AppBar_menu1,
R.styleable.AppBar_menu2, R.styleable.AppBar_menu3,
R.styleable.AppBar_menu4, R.styleable.AppBar_menu5};
List<Integer> menuIds = getResIds(styleableResIds, a);
a.recycle();
// 1.set nav button
ImageButton navButton = getNavButton();
if (navButton != null) {
Toolbar.LayoutParams lp = (LayoutParams) navButton.getLayoutParams();
if (!TextUtils.equals(navBtnGravity, "0")) {
lp.gravity = Gravity.CENTER_VERTICAL;
}
navButton.setLayoutParams(lp);
}
// 2.set menu views
for (int i = 0; i < menuIds.size(); i++) {
int menuId = menuIds.get(i);
if (menuId == 0) {
continue;
}
final View menuV = initMenuVIew(context, menuId);
menuList.add(menuV);
addView(menuV, menuLp);
}
}
代码示例来源:origin: BlinkID/blinkid-android
@Override
public void onSizeChanged(int width, int height) {
Log.d(this, "[onSizeChanged] Width:{}, Height:{}", width, height);
int horizontalMargin = (int) (width * 0.07);
int verticalMargin = (int) (height * 0.07);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
int tmp = horizontalMargin;
horizontalMargin = verticalMargin;
verticalMargin = tmp;
}
if (mBackButton != null) {
// set margins for back button
FrameLayout.LayoutParams backButtonParams = (FrameLayout.LayoutParams) mBackButton.getLayoutParams();
if (backButtonParams.leftMargin != horizontalMargin || backButtonParams.topMargin != verticalMargin) {
backButtonParams.setMargins(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
mBackButton.setLayoutParams(backButtonParams);
}
}
if (mTorchButton != null) {
// set margins for torch button
FrameLayout.LayoutParams torchButtonParams = (FrameLayout.LayoutParams) mTorchButton.getLayoutParams();
if (torchButtonParams.leftMargin != horizontalMargin || torchButtonParams.topMargin != verticalMargin) {
torchButtonParams.setMargins(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
mTorchButton.setLayoutParams(torchButtonParams);
}
}
}
代码示例来源:origin: blinkinput/blinkinput-android
@Override
public void onSizeChanged(int width, int height) {
Log.d(this, "[onSizeChanged] Width:{}, Height:{}", width, height);
int horizontalMargin = (int) (width * 0.07);
int verticalMargin = (int) (height * 0.07);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
int tmp = horizontalMargin;
horizontalMargin = verticalMargin;
verticalMargin = tmp;
}
if (mBackButton != null) {
// set margins for back button
FrameLayout.LayoutParams backButtonParams = (FrameLayout.LayoutParams) mBackButton.getLayoutParams();
if (backButtonParams.leftMargin != horizontalMargin || backButtonParams.topMargin != verticalMargin) {
backButtonParams.setMargins(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
mBackButton.setLayoutParams(backButtonParams);
}
}
if (mTorchButton != null) {
// set margins for torch button
FrameLayout.LayoutParams torchButtonParams = (FrameLayout.LayoutParams) mTorchButton.getLayoutParams();
if (torchButtonParams.leftMargin != horizontalMargin || torchButtonParams.topMargin != verticalMargin) {
torchButtonParams.setMargins(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
mTorchButton.setLayoutParams(torchButtonParams);
}
}
}
};
代码示例来源:origin: NASAWorldWind/WorldWindAndroid
LinearLayout.LayoutParams layout3 = (LinearLayout.LayoutParams) splitter.getLayoutParams();
代码示例来源:origin: jamorham/xDrip-plus
((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).leftMargin = 0;
((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).leftMargin = 0;
((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).setMarginStart(0);
((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).setMarginStart(0);
((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).rightMargin = 0;
((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).rightMargin = 0;
btnApprove.setScaleX(button_scale_factor);
btnApprove.setScaleY(button_scale_factor);
代码示例来源:origin: NightscoutFoundation/xDrip
((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).leftMargin = 0;
((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).leftMargin = 0;
((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).setMarginStart(0);
((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).setMarginStart(0);
((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).rightMargin = 0;
((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).rightMargin = 0;
btnApprove.setScaleX(button_scale_factor);
btnApprove.setScaleY(button_scale_factor);
代码示例来源:origin: stackoverflow.com
lp = (LayoutParams) imageButton.getLayoutParams();
lp.topMargin = top - 58;
imageButton.setLayoutParams(lp);
代码示例来源:origin: appnexus/mobile-sdk-android
void expand(int w, int h, boolean custom_close,
final MRAIDImplementation caller,
AdWebView.MRAIDFullscreenListener listener) {
MRAIDChangeSize(w, h);
// Add a stock close_button button to the top right corner
close_button = ViewUtil.createCloseButton(this.getContext(), custom_close);
FrameLayout.LayoutParams blp = (LayoutParams) close_button.getLayoutParams();
// place the close button at the top right of the adview if it isn't fullscreen
if (!caller.owner.isFullScreen) {
if (getChildAt(0) != null) {
blp.rightMargin = (this.getMeasuredWidth()
- this.getChildAt(0).getMeasuredWidth()) / 2;
}
}
close_button.setLayoutParams(blp);
close_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
caller.close();
}
});
if (caller.owner.isFullScreen) {
mraidFullscreenExpand(caller, custom_close, listener);
} else {
// if not fullscreen, just add the close button
this.addView(close_button);
}
isMRAIDExpanded = true;
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
public void getViews() {
layout = (TextView) findViewById(R.id.screen_layout_button);
visuals = (TextView) findViewById(R.id.visuals_button);
dock = (TextView) findViewById(R.id.dock_button);
chooseFrag = (TextView) findViewById(R.id.choose_fragments_button);
help = (TextView) findViewById(R.id.help_button);
donate = (TextView) findViewById(R.id.donate_button);
klinkerApps = (TextView) findViewById(R.id.our_apps_button);
restartLauncher = (TextView) findViewById(R.id.restart_launcher_button);
overflow = (ImageButton) findViewById(R.id.overflow_button);
Utilities.applyTypeface(layout);
Utilities.applyTypeface(visuals);
Utilities.applyTypeface(dock);
Utilities.applyTypeface(chooseFrag);
Utilities.applyTypeface(help);
Utilities.applyTypeface(donate);
Utilities.applyTypeface(klinkerApps);
Utilities.applyTypeface(restartLauncher);
Utilities.applyTypeface((TextView) findViewById(R.id.fragment_settings));
Utilities.applyTypeface((TextView) findViewById(R.id.other_information));
Utilities.applyTypeface((TextView) findViewById(R.id.display_settings));
// set the margin for the status bar if they have transparent
if (Build.VERSION.SDK_INT >= 19) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) overflow.getLayoutParams();
params.setMargins(0, Utils.getStatusBarHeight(this), 0, 0); //substitute parameters for left, top, right, bottom
overflow.setLayoutParams(params);
}
}
内容来源于网络,如有侵权,请联系作者删除!