• Android不自动弹出软键盘和不让软键盘弹出挤压图形


    软键盘弹出挤压图形很变态,设计好的模型会在软件盘弹出数据变得丑陋无比,为了保持不变,只需要在

    Manifest.xml 相应的 Activity 里添加

    android:windowSoftInputMode="adjustPan|stateHidden"

    为了不让软件盘弹出,如果是Activity的话,可以直接添加如下代码解决自动弹出软键盘的问题

      <activity android:name="com.guandehao.baobiao.B_KuCunBaoBiao" 
                android:windowSoftInputMode="adjustPan|stateHidden"
                android:configChanges="orientation|keyboardHidden"/>

     还有就是不在Activity下的设置可能无效,如ActivityFragment,那直接可以使用下面这些方法,上面的设置可以保留。

    第一种方法:

    就是在不要弹出软件盘对应的EditText的父控件里添加

    android:focusable="true"
    android:focusableInTouchMode="true"

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"  
            android:focusableInTouchMode="true" 
        android:orientation="vertical" >

    这是我感觉最方便的一个方法,也有人如下解决办法

    这是第二种方法:

    在xml文件中加入一个隐藏的TextView:

    <TextView  
            android:id="@+id/config_hidden"  
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"  
            android:focusable="true"  
            android:focusableInTouchMode="true"  
            />

    然后再在Activity中加入:

    /**防止自动弹出软键盘*/
            TextView config_hidden = (TextView) view.findViewById(R.id.config_hidden);
            config_hidden.requestFocus();

    我推荐使用第一种方法,简洁。

  • 相关阅读:
    设置函数环境——setfenv(转)
    全局变量声明的规范化(转)
    利用__index和__newindex实现默认值表、监控表、只读表(转)
    php中的$_GET怎样获取带有井号“#”的參数
    Servlet配置load-on-startup
    LinQ—扩展方法
    CRT
    [C++] 获取IE代理server的账号password
    一步一步写算法(之hash表)
    android之PackageManager简单介绍
  • 原文地址:https://www.cnblogs.com/bxfx111/p/3877511.html
Copyright © 2020-2023  润新知