zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    1038 Recover the Smallest Number (30分) sort-cmp妙用(用于使字符串序列最小)
    1033 To Fill or Not to Fill (25分)贪心(???)
    1030 Travel Plan (30分) dij模板题
    1020 Tree Traversals (25分)(树的构造:后序+中序->层序)
    1022 Digital Library (30分) hash模拟
    1018 Public Bike Management (30分)(Dijkstra路径保存fa[]+DFS路径搜索)
    1017 Queueing at Bank (25分)模拟:关于事务排队处理
    1014 Waiting in Line (30分)队列模拟题
    1010 Radix (25分)暴力猜数or二分猜数
    HDU 3032 multi-sg 打表找规律
  • 原文地址:https://www.cnblogs.com/tinyclear/p/6278005.html
Copyright © 2011-2022 走看看