本文整理汇总了Java中android.widget.EditText.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setLayoutParams方法的具体用法?Java EditText.setLayoutParams怎么用?Java EditText.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setThemedContext
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void setThemedContext(ThemedReactContext themedContext) {
super.setThemedContext(themedContext);
// TODO #7120264: cache this stuff better
mEditText = new EditText(getThemedContext());
// This is needed to fix an android bug since 4.4.3 which will throw an NPE in measure,
// setting the layoutParams fixes it: https://code.google.com/p/android/issues/detail?id=75877
mEditText.setLayoutParams(
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
setDefaultPadding(Spacing.START, mEditText.getPaddingStart());
setDefaultPadding(Spacing.TOP, mEditText.getPaddingTop());
setDefaultPadding(Spacing.END, mEditText.getPaddingEnd());
setDefaultPadding(Spacing.BOTTOM, mEditText.getPaddingBottom());
mEditText.setPadding(0, 0, 0, 0);
}
示例2: setThemedContext
import android.widget.EditText; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void setThemedContext(ThemedReactContext themedContext) {
super.setThemedContext(themedContext);
mEditText = new EditText(themedContext);
// This is needed to fix an android bug since 4.4.3 which will throw an NPE in measure,
// setting the layoutParams fixes it: https://code.google.com/p/android/issues/detail?id=75877
mEditText.setLayoutParams(
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
setDefaultPadding(Spacing.START, mEditText.getPaddingStart());
setDefaultPadding(Spacing.TOP, mEditText.getPaddingTop());
setDefaultPadding(Spacing.END, mEditText.getPaddingEnd());
setDefaultPadding(Spacing.BOTTOM, mEditText.getPaddingBottom());
mEditText.setPadding(0, 0, 0, 0);
}
示例3: setEditViewsName
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 设置编辑列表VIEW
*
* @param names 编辑view 的name
* @return this
*/
public BaseDialog setEditViewsName(List<String> names) {
if (middleLayout.getChildCount() > 0) {
middleLayout.removeAllViews();
}
for (String name :
names) {
TextView textView = new TextView(getContext());
textView.setText(name);
EditText editText = new EditText(getContext());
editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
editText.setHint("请输入" + name);
editText.setPadding(10, 0, 0, 0);
editText.setHintTextColor(Color.BLUE);
LinearLayout child = new LinearLayout(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
child.setOrientation(LinearLayout.HORIZONTAL);
child.setGravity(Gravity.CENTER_VERTICAL);
child.setLayoutParams(params);
child.addView(textView);
child.addView(editText);
middleLayout.addView(child);
}
return this;
}
示例4: onBuildContent
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
int padding = QMUIDisplayHelper.dp2px(mContext, 20);
layout.setPadding(padding, padding, padding, padding);
mEditText = new EditText(mContext);
QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
mEditText.setHint("输入框");
LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
mEditText.setLayoutParams(editTextLP);
layout.addView(mEditText);
TextView textView = new TextView(mContext);
textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
"QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
"同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
"不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
layout.addView(textView);
return layout;
}
示例5: init
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 初始化操作
*/
private void init() {
ptrID1 = INVALID_POINTER_ID;
ptrID2 = INVALID_POINTER_ID;
mptrID1 = INVALID_POINTER_ID;
mptrID2 = INVALID_POINTER_ID;
list = new ArrayList<>();
listTvParams = new ArrayList<>();
listDistance = new ArrayList<>();
editText = new EditText(context);
editText.setLayoutParams(
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
editText.setVisibility(GONE);
addView(editText);
}
示例6: createCommentFilterDialog
import android.widget.EditText; //导入方法依赖的package包/类
/**
* Creates the sub-dialogue where you can enter the substring to search for
*/
private Dialog createCommentFilterDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final EditText input = new EditText(getActivity());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(layoutParams);
builder.setTitle("Filter habit events")
.setView(input)
.setPositiveButton("Search",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
listener.filterResult(FilterType.SEARCH_BY_COMMENT,
input.getText().toString());
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,
int i) {}
});
return builder.create();
}
示例7: generateOneEditText
import android.widget.EditText; //导入方法依赖的package包/类
/**
* Takes care of styling the editText passed in the param.
* tag is the index of the editText.
*
* @param styleEditText
* @param tag
*/
private void generateOneEditText(EditText styleEditText, String tag) {
params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
filters[0] = new InputFilter.LengthFilter(1);
styleEditText.setFilters(filters);
styleEditText.setLayoutParams(params);
styleEditText.setGravity(Gravity.CENTER);
styleEditText.setCursorVisible(mCursorVisible);
if (!mCursorVisible) {
styleEditText.setClickable(false);
styleEditText.setHint(mHint);
styleEditText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
mDelPressed = false;
return false;
}
});
}
styleEditText.setBackgroundResource(mPinBackground);
styleEditText.setPadding(0, 0, 0, 0);
styleEditText.setTag(tag);
styleEditText.setInputType(getKeyboardInputType());
styleEditText.addTextChangedListener(this);
styleEditText.setOnFocusChangeListener(this);
styleEditText.setOnKeyListener(this);
}
示例8: setSplitWidth
import android.widget.EditText; //导入方法依赖的package包/类
public void setSplitWidth(int splitWidth) {
this.mSplitWidth = splitWidth;
int margin = splitWidth / 2;
params.setMargins(margin, margin, margin, margin);
for (EditText editText : editTextList) {
editText.setLayoutParams(params);
}
}
示例9: setPinHeight
import android.widget.EditText; //导入方法依赖的package包/类
public void setPinHeight(int pinHeight) {
this.mPinHeight = pinHeight;
params.height = pinHeight;
for (EditText editText : editTextList) {
editText.setLayoutParams(params);
}
}
示例10: setPinWidth
import android.widget.EditText; //导入方法依赖的package包/类
public void setPinWidth(int pinWidth) {
this.mPinWidth = pinWidth;
params.width = pinWidth;
for (EditText editText : editTextList) {
editText.setLayoutParams(params);
}
}
示例11: showHighlightEditDialog
import android.widget.EditText; //导入方法依赖的package包/类
private void showHighlightEditDialog( final HighLight highLight ) {
final AlertDialog.Builder editalert = new AlertDialog.Builder( context );
editalert.setTitle(R.string.text_note);
final EditText input = new EditText(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
input.setLayoutParams(lp);
editalert.setView(input);
input.setText( highLight.getTextNote() );
editalert.setPositiveButton(R.string.save_note, (dialog, which) -> {
highLight.setTextNote(input.getText().toString());
bookView.update();
highlightManager.saveHighLights();
});
editalert.setNegativeButton(android.R.string.cancel, (dialog,which) -> {} );
editalert.setNeutralButton(R.string.clear_note, (dialog, which) -> {
highLight.setTextNote(null);
bookView.update();
highlightManager.saveHighLights();
});
editalert.show();
}
示例12: getMainBody
import android.widget.EditText; //导入方法依赖的package包/类
private LinearLayout getMainBody() {
LinearLayout llMainBody = new LinearLayout(getContext());
llMainBody.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lpMain = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpMain.weight = 1;
int dp_4 = dipToPx(getContext(), 4);
lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
llMainBody.setLayoutParams(lpMain);
LinearLayout llContent = new LinearLayout(getContext());
LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpContent.weight = 1;
llMainBody.addView(llContent, lpContent);
// 文字输入区域
etContent = new EditText(getContext());
etContent.setGravity(Gravity.LEFT | Gravity.TOP);
etContent.setBackgroundDrawable(null);
etContent.setText(String.valueOf(reqData.get("text")));
etContent.addTextChangedListener(this);
LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpEt.weight = 1;
etContent.setLayoutParams(lpEt);
llContent.addView(etContent);
llContent.addView(getThumbView());
llMainBody.addView(getBodyBottom());
return llMainBody;
}
示例13: createEditText
import android.widget.EditText; //导入方法依赖的package包/类
private EditText createEditText() {
LinearLayout.LayoutParams EditTextlayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
EditText editText = new EditText(getContext());
editText.setLayoutParams(EditTextlayoutParams);
editText.setHint(getString(R.string.answer, letters[inputLayout.getChildCount()]));
editText.setInputType(InputType.TYPE_CLASS_TEXT);
return editText;
}
示例14: createEditText
import android.widget.EditText; //导入方法依赖的package包/类
private EditText createEditText(){
LinearLayout.LayoutParams EditTextlayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
EditText editText = new EditText(this);
editText.setLayoutParams(EditTextlayoutParams);
editText.setHint(getString(R.string.editResult, letters[linearLayout.getChildCount()]));
return editText;
}
示例15: showAttributeDetail
import android.widget.EditText; //导入方法依赖的package包/类
private void showAttributeDetail(final String attributeType, final String attributeValue) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(attributeType);
final EditText input = new EditText(NewPassword.this);
input.setText(attributeValue);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
input.requestFocus();
builder.setView(input);
builder.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
String newValue = input.getText().toString();
if (!newValue.equals(attributeValue)) {
refreshItemsDisplayed();
}
mUserDialog.dismiss();
} catch (Exception e) {
Log.e(AppUtility.TAG, Log.getStackTraceString(e));
}
}
});
mUserDialog = builder.create();
mUserDialog.show();
}