本文整理汇总了Java中android.widget.EditText.setGravity方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setGravity方法的具体用法?Java EditText.setGravity怎么用?Java EditText.setGravity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setGravity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EditTextDialogBuilder
import android.widget.EditText; //导入方法依赖的package包/类
public EditTextDialogBuilder(Context context) {
super(context);
mEditText = new EditText(mContext);
mEditText.setHintTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_3));
mEditText.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_black));
mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_message_text_size));
mEditText.setFocusable(true);
mEditText.setFocusableInTouchMode(true);
mEditText.setImeOptions(EditorInfo.IME_ACTION_GO);
mEditText.setGravity(Gravity.CENTER_VERTICAL);
mEditText.setId(R.id.qmui_dialog_edit_input);
mRightImageView = new ImageView(mContext);
mRightImageView.setId(R.id.qmui_dialog_edit_right_icon);
mRightImageView.setVisibility(View.GONE);
}
示例2: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_controller);
setTitle("PTP协议测试");
// 注册按钮点击事件
((Button) findViewById(R.id.allUsbDevices)).setOnClickListener(this);
((Button) findViewById(R.id.connectToDevices)).setOnClickListener(this);
((Button) findViewById(R.id.getDevicePTPInfo)).setOnClickListener(this);
((Button) findViewById(R.id.getAllObjects)).setOnClickListener(this);
((Button) findViewById(R.id.transferObject)).setOnClickListener(this);
((Button) findViewById(R.id.getObjectInfo)).setOnClickListener(this);
((Button) findViewById(R.id.updateExif)).setOnClickListener(this);
etPtpObjectName = (EditText) findViewById(R.id.ptpObject);
etPtpObjectInfoName = (EditText) findViewById(R.id.ptpObjectInfo);
etLogPanel = (EditText) findViewById(R.id.logPanel);
etLogPanel.setGravity(Gravity.BOTTOM);
log("程序初始化完成");
registerUsbDeviceReceiver();
}
示例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: getMainBody
import android.widget.EditText; //导入方法依赖的package包/类
private LinearLayout getMainBody() {
LinearLayout llMainBody = new LinearLayout(getContext());
llMainBody.setOrientation(LinearLayout.VERTICAL);
LayoutParams lpMain = new 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());
LayoutParams lpContent = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpContent.weight = 1;
llMainBody.addView(llContent, lpContent);
// share content editor
etContent = new EditText(getContext());
etContent.setGravity(Gravity.LEFT | Gravity.TOP);
etContent.setBackgroundDrawable(null);
etContent.setText(String.valueOf(shareParamMap.get("text")));
etContent.addTextChangedListener(this);
LayoutParams lpEt = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpEt.weight = 1;
etContent.setLayoutParams(lpEt);
llContent.addView(etContent);
llContent.addView(getThumbView());
llMainBody.addView(getBodyBottom());
return llMainBody;
}
示例5: 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;
}
示例6: init
import android.widget.EditText; //导入方法依赖的package包/类
private void init(Context context) {
setClipToPadding(false);
FrameLayout.LayoutParams linearLayoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
linearLayoutParams.gravity = Gravity.CENTER;
FrameLayout.LayoutParams editTextLayoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editTextLayoutParams.gravity = Gravity.CENTER;
animatedPlaceholder = new LinearLayout(context);
animatedPlaceholder.setVisibility(INVISIBLE);
animatedPlaceholder.setOrientation(LinearLayout.HORIZONTAL);
animatedPlaceholder.setClipToPadding(false);
animatedPlaceholder.setPadding(0, 20, 0, 0);
actualEditText = new EditText(context);
actualEditText.setBackground(null);
actualEditText.setGravity(Gravity.CENTER);
actualEditText.setIncludeFontPadding(false);
actualEditText.setVisibility(INVISIBLE);
actualEditText.setPadding(0, 20, 0, 0);
if (!TextUtils.isEmpty(text)) actualEditText.setText(text);
if (!TextUtils.isEmpty(hint)) actualEditText.setHint(hint);
if (textColor != -1) actualEditText.setTextColor(textColor);
if (hintColor != -1) actualEditText.setHintTextColor(hintColor);
if (textSize != -1) actualEditText.setTextSize(textSize);
addView(animatedPlaceholder, linearLayoutParams);
addView(actualEditText, editTextLayoutParams);
if (autoStart) startAnimation();
}
示例7: addEts
import android.widget.EditText; //导入方法依赖的package包/类
private void addEts() {
for (int i = 0; i < 9; i++) {
EditText et = new EditText(getActivity());
et.setGravity(Gravity.CENTER);
mETs[i] = et;
mGridGroup.addView(et, mEtWidth, mEtHeight);
}
}
示例8: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdf);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setLogo(R.drawable.ic_notify);
toolbar.setTitle("PdfView");
// toolbar.setTitleTextColor(Color.RED);
setSupportActionBar(toolbar);
imgPdf=(ImageView)findViewById(R.id.image_pdf);
mAttacher = new PhotoViewAttacher(imgPdf);
txtTitle=(TextView) findViewById(R.id.toolbar_title);
txtTitle.setGravity(Gravity.START);
// txtTitle.setBackgroundColor(Color.RED);
edtPage=(EditText) findViewById(R.id.toolbar_page);
edtPage.setGravity(Gravity.END|Gravity.CENTER);
// edtPage.setBackgroundColor(Color.YELLOW);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
Intent intent = getIntent();
if (intent != null) {
log.d("oncreate "+intent.toString());
String action = intent.getAction();
if (intent.ACTION_VIEW.equals(action)) {
uri = intent.getData();
log.d("ACTION_VIEW uri "+ uri.toString());
openRenderer( );
if(mPdfRenderer!=null)
showPage(index);
}
}
}
示例9: onCreateView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_edit, container, false);
CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
int index = getArguments().getInt("INDEX");
Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(m.GetRow());
gridLayout.setColumnCount(m.GetCol());
for (int i = 0; i < m.GetRow(); i++) {
for (int j = 0; j < m.GetCol(); j++) {
EditText editText = new EditText(getContext());
editText.setId(i * 10 + j);
editText.setGravity(Gravity.CENTER);
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED);
} else {
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED);
}
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
editText.setWidth(ConvertTopx(62));
editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
} else {
editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
}
editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
editText.setSingleLine();
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(editText, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
RootView = V;
return V;
}