• Android:关于Edittext的一些设置


    1.自动弹出输入框.

      et_order_search.setFocusableInTouchMode(true);
                et_order_search.requestFocus();
                CmzBossApplication.handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        InputMethodManager inputManager = (InputMethodManager) et_order_search.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                        inputManager.showSoftInput(et_order_search, 0);
                    }
                }, 200);

    2.不显示下划线 ,光标颜色设置.

                <EditText
                    android:textCursorDrawable="@drawable/color_cursor"//这里只能是drawable,不能直接设置color;如果不设置则默认是红色的光标,但是设置成@null,颜色会和字体颜色一致,但是位置不对.
                    android:id="@+id/aof_et_orderSearch"
                    android:background="@null"
                    android:singleLine="true"
                    android:textColor="@color/blue_l"
                    android:textColorHint="@color/blue_l"
                    android:hint="请输入订单号"
                    android:gravity="center"
                    android:layout_marginRight="52dp"
                    android:layout_marginLeft="@dimen/dp20"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>

    3.光标颜色设置

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
        <size android:width="1dp" />
        <solid android:color="@color/blue_l"  />
    </shape>

    4.EditText会把整个布局网上顶,有时候我们需要这种,但是有时候却不需要.所以需要设置Activity的一些属性.

     getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);//不让输入法往上顶!
            setContentView(R.layout.activity_order_form_layout);
    _______________________________________________________________________________________________________________________________________________ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    //输入法往上顶. setContentView(R.layout.activity_order_form_layout);

     5.dialog中弹出键盘.获取焦点的代码.

    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
    WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
  • 相关阅读:
    EF Core使用笔记(基于MySql数据库)
    开发环境---->服务器(数据库迁移Migration)
    正向代理和反向代理
    Linux基础命令
    Git + Docker + Jenkins自动化部署web到Linux(Centos)
    poj3320(尺取法)
    poj3061(尺取法)
    51nod 1092(lcs)回文字符串
    51nod1268(基础dfs)
    51nod-1459-迷宫游戏
  • 原文地址:https://www.cnblogs.com/tinyclear/p/6278005.html
Copyright © 2020-2023  润新知