本文介绍了如何在Android中动态设置保证金?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前做的,它包含自定义警告对话框Android应用程序。它包含一个按钮,但我不能设置保证金的按钮。的code为如下。 setmargin方法是行不通的。
AlertDialog.Builder myDialog =新AlertDialog.Builder(Login.this);
Button按钮=新按钮(Login.this);
button.setText(发送);
的LayoutParams buttonLayoutParams
=新的LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
button.setLayoutParams(buttonLayoutParams);
。resetPassword = editText.getText()的toString();
的LinearLayout布局=新的LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(TextView的);
layout.addView(EDITTEXT);
layout.addView(按钮);
myDialog.setView(布局);
解决方案
写操作之后code来设置保证金,它可以帮助你。
AlertDialog.Builder myDialog =新AlertDialog.Builder(Login.this);
Button按钮=新按钮(Login.this);
EditText上EDITTEXT =新的EditText(Login.this);
TextView中的TextView =新的TextView(Login.this);
button.setText(发送);
LinearLayout.LayoutParams buttonLayoutParams =新LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
buttonLayoutParams.setMargins(50,10,0,0);
button.setLayoutParams(buttonLayoutParams);
。字符串resetPassword = editText.getText()的toString();
的LinearLayout布局=新的LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(TextView的);
layout.addView(EDITTEXT);
layout.addView(按钮);
myDialog.setView(布局);
myDialog.show();
根据孩子认为家长布局使用LinearLayout.LayoutParams或RelativeLayout.LayoutParams
I am currently doing an android application that contains customize alert dialog. It contains a button , but i can't set the margin for the button . the code is given below. setmargin method is not working
AlertDialog.Builder myDialog = new AlertDialog.Builder(Login.this);
Button button = new Button(Login.this);
button.setText("Send");
LayoutParams buttonLayoutParams
= new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
button.setLayoutParams(buttonLayoutParams);
resetPassword=editText.getText().toString();
LinearLayout layout = new LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(editText);
layout.addView(button);
myDialog.setView(layout);
解决方案
Write Following Code to set Margin, it may help you.
AlertDialog.Builder myDialog = new AlertDialog.Builder(Login.this);
Button button = new Button(Login.this);
EditText editText = new EditText(Login.this);
TextView textView = new TextView(Login.this);
button.setText("Send");
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
buttonLayoutParams.setMargins(50, 10, 0, 0);
button.setLayoutParams(buttonLayoutParams);
String resetPassword = editText.getText().toString();
LinearLayout layout = new LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(editText);
layout.addView(button);
myDialog.setView(layout);
myDialog.show();
Use LinearLayout.LayoutParams or RelativeLayout.LayoutParams according to parent layout of the child view
这篇关于如何在Android中动态设置保证金?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!