本文整理了Java中android.widget.Button.setLayoutParams()
方法的一些代码示例,展示了Button.setLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setLayoutParams()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setLayoutParams
暂无
代码示例来源:origin: stackoverflow.com
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
Button button1;
button1.setLayoutParams(params);
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.RIGHT_OF, button1.getId());
Button button2;
button2.setLayoutParams(params);
代码示例来源:origin: googlemaps/android-maps-utils
private void addDemo(String demoName, Class<? extends Activity> activityClass) {
Button b = new Button(this);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
b.setLayoutParams(layoutParams);
b.setText(demoName);
b.setTag(activityClass);
b.setOnClickListener(this);
mListView.addView(b);
}
代码示例来源:origin: daniulive/SmarterStreaming
btnPlaybackPopInputUrl.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btnPlaybackMute.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
firstLineLinearLayout.addView(btnPlaybackMute);
btnPlaybackHardwareDecoder.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
firstLineLinearLayout.addView(btnPlaybackHardwareDecoder);
btnPlaybackSetPlayBuffer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
bufferLinearLayout.addView(btnPlaybackSetPlayBuffer);
btnPlaybackFastStartup.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
bufferLinearLayout.addView(btnPlaybackFastStartup);
btnPlaybackStartStopPlayback.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnPlaybackStartStopPlayback);
代码示例来源:origin: cSploit/android
Button choice = new Button(activity);
choice.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.5f));
choice.setTag("" + i);
choice.setOnClickListener(new View.OnClickListener(){
代码示例来源:origin: jaydenxiao2016/AndroidFire
private Button getButton(String text, int position) {
// 动态生成选择按钮
final Button button = new Button(mContext);
button.setText(text);
button.setTag(position);
button.setTextColor(mBuilder.getItemTextColor());
button.setTextSize(mBuilder.getItemTextSize());
button.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams
.MATCH_PARENT, mBuilder.getItemHeight()));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (mBuilder.getOnItemListener() != null) {
selectPosition = Integer.parseInt(button.getTag().toString());
mBuilder.getOnItemListener().onItemClick(button, selectPosition);
}
}
});
return button;
}
代码示例来源:origin: daniulive/SmarterStreaming
btnPopInputUrl.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnPopInputUrl);
btnPopInputRelayUrl.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnPopInputRelayUrl);
btnMute.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnMute);
btnSwitchUrl.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnSwitchUrl);
btnCaptureImage.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
LinearLayoutImage.addView(btnCaptureImage);
btnRotation.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
LinearLayoutImage.addView(btnRotation);
btnHardwareDecoder.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lLinearLayout.addView(btnHardwareDecoder);
btnSetPlayBuffer.setLayoutParams(new LayoutParams(
代码示例来源:origin: jaydenxiao2016/AndroidFire
.MATCH_PARENT, mBuilder.getItemHeight());
btnlp.topMargin = 10;
bottomBtn.setLayoutParams(btnlp);
代码示例来源:origin: jaydenxiao2016/AndroidFire
private Button getButton(String text, int position) {
// 动态生成选择按钮
final Button button = new Button(mContext);
button.setText(text);
button.setTag(position);
button.setTextColor(mBuilder.getItemTextColor());
button.setTextSize(mBuilder.getItemTextSize());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
.MATCH_PARENT, mBuilder.getItemHeight());
button.setLayoutParams(lp);
button.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
button.setPadding(UiUtils.dp2px(mContext,10),0,UiUtils.dp2px(mContext,10),0);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (mBuilder.getOnItemListener() != null) {
selectPosition = Integer.parseInt(button.getTag().toString());
mBuilder.getOnItemListener().onItemClick(button, selectPosition);
}
}
});
return button;
}
代码示例来源:origin: termux/termux-app
param.columnSpec = GridLayout.spec(col, GridLayout.FILL, 1.f);
param.rowSpec = GridLayout.spec(row, GridLayout.FILL, 1.f);
button.setLayoutParams(param);
代码示例来源:origin: chrisk44/Hijacker
@Override
public void onAnimationUpdate(ValueAnimator animation){
ViewGroup.LayoutParams layoutparams = speedTestBtn.getLayoutParams();
layoutparams.width = (int)animation.getAnimatedValue();
speedTestBtn.setLayoutParams(layoutparams);
}
});
代码示例来源:origin: chrisk44/Hijacker
@Override
public void onAnimationUpdate(ValueAnimator animation){
ViewGroup.LayoutParams layoutParams = speedTestBtn.getLayoutParams();
layoutParams.width = (int)animation.getAnimatedValue();
speedTestBtn.setLayoutParams(layoutParams);
}
});
代码示例来源:origin: stackoverflow.com
Button yourBtn = (Button) findViewById.(R.id.yourBtn);
int btnSize=yourBtn.getLayoutParams().width;
yourBtn.setLayoutParams(new LayoutParams(btnSize, btnSize));
代码示例来源:origin: google/android-ui-toolkit-demos
LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
params.weight = weight;
button.setLayoutParams(params);
button.setText("F out L in");
button.setOnClickListener(new View.OnClickListener() {
代码示例来源:origin: waynell/VideoListPlayer
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view);
ButterKnife.bind(this);
final MyAdapter adapter = new MyAdapter();
mCalculator = new SingleListViewItemActiveCalculator(adapter, new ListViewItemPositionGetter(mListView));
// add hear here
for (int i = 0; i < HEADER_COUNT; i++) {
Button header = new Button(this);
header.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
header.setText("Header");
mListView.addHeaderView(header);
}
mListView.setAdapter(adapter);
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
mScrollState = scrollState;
if(scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && adapter.getCount() > 0){
mCalculator.onScrollStateIdle();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
mCalculator.onScrolled(mScrollState);
}
});
}
代码示例来源:origin: chrisk44/Hijacker
speedTestBtn.setLayoutParams(layoutParams);
}else if(normalOptHeight!=-1 && normalTestBtnWidth!=-1){
ViewGroup.LayoutParams params = optionsContainer.getLayoutParams();
speedTestBtn.setLayoutParams(params);
代码示例来源:origin: stackoverflow.com
FrameLayout layout = (FrameLayout) findViewById(R.layout.frame_layout);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(30, 10, 0, 0);
Button btn = (Button) findViewById(R.id.rbutton);
btn.setLayoutParams(params);
btn.requestLayout();
代码示例来源:origin: stackoverflow.com
Button button = (Button)findViewById(R.id.my_button);
AbsoluteLayout.LayoutParams absParams =
(AbsoluteLayout.LayoutParams)button.getLayoutParams();
absParams.x = myNewX;
absParams.y = myNewY;
button.setLayoutParams(absParams);
代码示例来源:origin: stackoverflow.com
final Button buttonStudy = (Button) findViewById(R.id.button_study);
buttonStudy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup.LayoutParams params = buttonStudy.getLayoutParams();
params.width = 100;//change the width size
params.height= 100;//change the hight size
buttonStudy.setLayoutParams(params);
}
});
代码示例来源:origin: stackoverflow.com
Button button = (Button)findViewById(R.id.my_button);
AbsoluteLayout.LayoutParams absParams =
(AbsoluteLayout.LayoutParams)button.getLayoutParams();
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
int height = displaymetrics.heightPixels;
Random r = new Random();
absParams.x = r.nextInt(width ) ;
absParams.y = r.nextInt(height );
button.setLayoutParams(absParams);
代码示例来源:origin: AmazMod/AmazMod
public void setButtonParams(Button button, String text, Boolean mode) {
if (mode) {
params.setMargins(20, 12, 20, 12);
button.setLayoutParams(params);
}
button.setPadding(0,15,0,15);
button.setIncludeFontPadding(false);
button.setMinHeight(36);
button.setText(text);
button.setAllCaps(true);
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeSP);
}
内容来源于网络,如有侵权,请联系作者删除!