本文整理匯總了Java中android.widget.EditText.setPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.setPadding方法的具體用法?Java EditText.setPadding怎麽用?Java EditText.setPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setPadding方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTextInputMeasurements
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 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());
}
示例2: 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);
}
示例3: 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);
}
示例4: createEditText
import android.widget.EditText; //導入方法依賴的package包/類
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;
}
示例5: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
changeStatusBarColor();
username = (EditText) findViewById(R.id.et_username);
username.setPadding(0,15,0,15);
email = (EditText) findViewById(R.id.et_email);
email.setPadding(0,15,0,15);
password= (EditText) findViewById(R.id.et_password);
password.setPadding(0,15,0,15);
ll_button = (LinearLayout) findViewById(R.id.ll_button);
ll_bottom = (LinearLayout) findViewById(R.id.ll_bottom);
ease(ll_button);
ease2(ll_bottom);
iv_back = (ImageView) findViewById(R.id.iv_back);
iv_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(SignUp.this, MainActivity.class));
finish();
}
});
}
示例6: initBody
import android.widget.EditText; //導入方法依賴的package包/類
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);
}
示例7: initBody
import android.widget.EditText; //導入方法依賴的package包/類
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);
}