Java Code Examples for android.widget.EditText#setPadding()
The following examples show how to use
android.widget.EditText#setPadding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditTextSettingsCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public EditTextSettingsCell(Context context) { super(context); textView = new EditText(context); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); textView.setBackgroundDrawable(null); textView.setPadding(0, 0, 0, 0); textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); }
Example 2
Source File: TextInputTestCase.java From react-native-GPay with MIT License | 6 votes |
/** * Test that the actual height of the text input is not dependant on the font size of the text * within. */ public void testTextInputMeasurements() { View textInputViewHeightSet = getViewByTestId("textInput1"); EditText textInputViewNoHeight = getViewByTestId("textInput2"); int expectedHeight = Math.round(PixelUtil.toPixelFromDIP(30)); assertEquals(expectedHeight, textInputViewHeightSet.getHeight()); EditText editText = new EditText(textInputViewNoHeight.getContext()); editText.setTextSize( TypedValue.COMPLEX_UNIT_PX, (float) Math.ceil(PixelUtil.toPixelFromSP(21.f))); editText.setPadding(0, 0, 0, 0); int measureSpec = View.MeasureSpec.makeMeasureSpec( ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED); editText.measure(measureSpec, measureSpec); assertEquals(editText.getMeasuredHeight(), textInputViewNoHeight.getHeight()); }
Example 3
Source File: BaseDialog.java From TestChat with Apache License 2.0 | 6 votes |
/** * 设置编辑列表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; }
Example 4
Source File: DialogUtil.java From xposed-rimet with Apache License 2.0 | 5 votes |
/** * 显示编辑的Dialog提示框 */ public static void showEditDialog(Context context, String title, String content, String contentHint, final OnEditListener listener) { int top = DisplayUtil.dip2px(context, 20f); int left = DisplayUtil.dip2px(context, 26f); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setLayoutParams(LayoutUtil.newFrameLayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); frameLayout.setPadding(left, top, left, 0); int padding = DisplayUtil.dip2px(context, 5); final EditText editText = new EditText(context); editText.setPadding(padding, padding, padding, padding); editText.setTextSize(15); editText.setText(content); editText.setLayoutParams(LayoutUtil.newViewGroupParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setSingleLine(true); editText.setFilters(new InputFilter[]{ new InputFilter.LengthFilter(10)}); editText.setHint(contentHint); ViewUtil.setInputType(editText, com.sky.xposed.common.Constant.InputType.TEXT); frameLayout.addView(editText); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); builder.setView(frameLayout); builder.setPositiveButton("确定", (dialog, which) -> { // 返回文本的内容 listener.onTextChange(editText, editText.getText().toString()); }); builder.setNegativeButton("取消", null); builder.show(); }
Example 5
Source File: ProfileLayout.java From kakao-android-sdk-standalone with Apache License 2.0 | 5 votes |
/** * 사용자 정보를 layout에 그려준다. */ @Override protected void onAttachedToWindow () { super.onAttachedToWindow(); View view = inflate(getContext(), R.layout.kakao_profile_layout, this); profile = (ImageView) view.findViewById(R.id.com_kakao_profile_image); if (profileImageURL != null) setProfileURL(profileImageURL); if (!editable) { ImageView editableMark = (ImageView) view.findViewById(R.id.profile_edit); editableMark.setVisibility(View.INVISIBLE); } nicknameText = (EditText) view.findViewById(R.id.com_kakao_profile_nickname); if (!editable) { nicknameText.setEnabled(false); nicknameText.setKeyListener(null); setBackgroundCompat(nicknameText, null); nicknameText.setPadding(0, 0, 0, 0); nicknameText.setTextColor(getResources().getColor(R.color.com_kakao_profile_text)); } if (nickname != null) nicknameText.setText(nickname); userIdText = (TextView) view.findViewById(R.id.com_kakao_profile_userId); if (userId != null) userIdText.setText(userId); }
Example 6
Source File: TemplatesActivity.java From J2ME-Loader with Apache License 2.0 | 5 votes |
private void showRenameDialog(final int id) { Template template = (Template) adapter.getItem(id); EditText editText = new EditText(this); editText.setText(template.getName()); float density = getResources().getDisplayMetrics().density; LinearLayout linearLayout = new LinearLayout(this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int margin = (int) (density * 20); params.setMargins(margin, 0, margin, 0); linearLayout.addView(editText, params); int paddingVertical = (int) (density * 16); int paddingHorizontal = (int) (density * 8); editText.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical); AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.action_context_rename) .setView(linearLayout) .setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { String newName = editText.getText().toString().trim(); if (newName.equals("")) { Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show(); } else { template.renameTo(newName); adapter.renameItem(id, template); } }) .setNegativeButton(android.R.string.cancel, null); builder.show(); }
Example 7
Source File: PatientIdElement.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * {@inheritDoc} */ @Override protected View createView(Context c) { et = new EditText(c); et.setPadding(10, 5, 10, 5); et.setText(answer); et.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); et.setGravity(Gravity.CENTER_HORIZONTAL); et.setKeyListener(new DialerKeyListener()); LinearLayout ll = new LinearLayout(c); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(et, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); //SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c); boolean barcodeEnable = true; //sp.getBoolean(Constants.PREFERENCE_BARCODE_ENABLED, false); if (barcodeEnable) { barcodeButton = new Button(c); barcodeButton.setText(c.getResources().getString( R.string.procedurerunner_scan_id)); barcodeButton.setOnClickListener(this); barcodeButton.setGravity(Gravity.CENTER_HORIZONTAL); ll.addView(barcodeButton, new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } return encapsulateQuestion(c, ll); }
Example 8
Source File: TagFlowLayout.java From support with Apache License 2.0 | 5 votes |
public TagFlowLayout(Context context, AttributeSet attrs) { super(context, attrs); mInputView = new EditText(context); mInputView.setBackgroundColor(Color.TRANSPARENT); mInputView.addTextChangedListener(this); mInputView.setOnKeyListener(this); mInputView.setPadding(0, 0, 0, 0); mInputView.setMinWidth(20); mInputView.setSingleLine(); mInputView.setGravity(Gravity.CENTER_VERTICAL); setDecorator(new SimpleDecorator(context)); addView(mInputView); setOnClickListener(this); previewInEditMode(); }
Example 9
Source File: EditorView.java From Nimbus with GNU General Public License v3.0 | 5 votes |
private EditText createEditText(String hint, int Padding) { EditText editText = (EditText) inflater.inflate(R.layout.item_edittext, null); editText.setTag(viewTag++); editText.setOnFocusChangeListener(focusChangeListener); editText.setOnKeyListener(keyListener); editText.setPadding(dip2px(EDIT_PADDING_TOP), Padding, dip2px(EDIT_PADDING_TOP), 0); editText.setHint(hint); return editText; }
Example 10
Source File: EditPagePort.java From LiuAGeAndroid with MIT License | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.VERTICAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 11
Source File: EditPageLand.java From LiuAGeAndroid with MIT License | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.HORIZONTAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 12
Source File: EditPagePort.java From Mobike with Apache License 2.0 | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.VERTICAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 13
Source File: EditPagePort.java From enjoyshop with Apache License 2.0 | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.VERTICAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 14
Source File: EditPageLand.java From enjoyshop with Apache License 2.0 | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.HORIZONTAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 15
Source File: EditPageLand.java From BaoKanAndroid with MIT License | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.HORIZONTAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 16
Source File: EditPageLand.java From GithubApp with Apache License 2.0 | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.HORIZONTAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
Example 17
Source File: CreateTicket.java From faveo-helpdesk-android-app with Open Software License 3.0 | 4 votes |
private void setErrorState(EditText editText, TextView textViewError, String error) { editText.setBackgroundResource(R.drawable.edittext_error_state); editText.setPadding(0, paddingTop, 0, paddingBottom); textViewError.setText(error); }
Example 18
Source File: WvWebView.java From YCWebView with Apache License 2.0 | 4 votes |
@Override public boolean onJsPrompt(WebView view, String url, final String message, String defaultValue, final JsPromptResult result) { if(Build.VERSION.SDK_INT<= Build.VERSION_CODES.JELLY_BEAN){ String prefix="_wvjbxx"; if(message.equals(prefix)){ Message msg = mainThreadHandler.obtainMessage(HANDLE_MESSAGE, defaultValue); mainThreadHandler.sendMessage(msg); } return true; } if(!alertBoxBlock){ result.confirm(); } final EditText editText = new EditText(getContext()); editText.setText(defaultValue); if (defaultValue != null) { editText.setSelection(defaultValue.length()); } float dpi = getContext().getResources().getDisplayMetrics().density; DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if(alertBoxBlock) { if (which == Dialog.BUTTON_POSITIVE) { result.confirm(editText.getText().toString()); } else { result.cancel(); } } } }; new AlertDialog.Builder(getContext()) .setTitle(message) .setView(editText) .setCancelable(false) .setPositiveButton(android.R.string.ok, listener) .setNegativeButton(android.R.string.cancel, listener) .show(); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int t = (int) (dpi * 16); layoutParams.setMargins(t, 0, t, 0); layoutParams.gravity = Gravity.CENTER_HORIZONTAL; editText.setLayoutParams(layoutParams); int padding = (int) (15 * dpi); editText.setPadding(padding - (int) (5 * dpi), padding, padding, padding); return true; }
Example 19
Source File: EditFragment.java From pandora with Apache License 2.0 | 4 votes |
@Override protected View getLayoutView() { View wrapper; editText = new EditText(getContext()); int padding = ViewKnife.dip2px(16); editText.setPadding(padding, padding, padding, padding); editText.setBackgroundColor(Color.WHITE); editText.setGravity(Gravity.START | Gravity.TOP); editText.setTextColor(ViewKnife.getColor(R.color.pd_label_dark)); editText.setLineSpacing(0, 1.2f); String[] options = getArguments().getStringArray(PARAM3); if (options != null && options.length > 0) { LinearLayout layout = new LinearLayout(getContext()); layout.setOrientation(LinearLayout.VERTICAL); wrapper = layout; RecyclerView recyclerView = new RecyclerView(getContext()); recyclerView.setBackgroundColor(Color.WHITE); LinearLayoutManager manager = new LinearLayoutManager(getContext()); manager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(manager); UniversalAdapter adapter = new UniversalAdapter(); recyclerView.setAdapter(adapter); adapter.setListener(new UniversalAdapter.OnItemClickListener() { @Override public void onItemClick(int position, BaseItem item) { notifyResult(((OptionItem)item).data); } }); List<BaseItem> items = new ArrayList<>(options.length); for (String option : options) { items.add(new OptionItem(option)); } adapter.setItems(items); LinearLayout.LayoutParams recyclerParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewKnife.dip2px(50) ); layout.addView(recyclerView, recyclerParam); LinearLayout.LayoutParams editParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ); layout.addView(editText, editParam); } else { wrapper = editText; } return wrapper; }
Example 20
Source File: EditPagePort.java From MyHearts with Apache License 2.0 | 4 votes |
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.VERTICAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }