當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。