当前位置: 首页>>代码示例>>Java>>正文


Java EditText.setGravity方法代码示例

本文整理汇总了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);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:17,代码来源:QMUIDialog.java

示例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();
}
 
开发者ID:iyundong,项目名称:InstantUpload,代码行数:26,代码来源:ControllerActivity.java

示例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);
}
 
开发者ID:GoodieBag,项目名称:Pinview,代码行数:37,代码来源:Pinview.java

示例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;
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:34,代码来源:EditPage.java

示例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;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:34,代码来源:EditPage.java

示例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();
    }
 
开发者ID:mcassiano,项目名称:cute-currency-view,代码行数:37,代码来源:CuteCurrencyView.java

示例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);
  }
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:9,代码来源:MatrixTestUI.java

示例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);
            }
        }
    }
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:44,代码来源:PdfActivity.java

示例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;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:60,代码来源:EditFragment.java


注:本文中的android.widget.EditText.setGravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。