1.   阿里云服务器1888元代金券领取
  2.   本网站所有源码包解压密码:www.youhutong.com
登录  帮助问答

Android 如何让EditText不自动获取焦点,不自动调出软键盘

小川 技术文章
郑重声明:
  本站发布的内容仅限用于学习和研究目的.请勿用于商业或非法用途,否则后果请用户自负,下载后请24小时内删除。 本站所有内容均不能保证其完整性,不提供任何技术支持,不能接受请勿购买或下载,如需完整程序,请去其官方购买正版使用。

解决办法:

在EditText的父级控件中找一个控件,添加两个属性:

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

如:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!--顶部搜索框-->
    <LinearLayout
        android:id="@+id/topSearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/appTitle"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:paddingTop="20dp"
        android:gravity="center"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/main_login_btn"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/login"/>
        <EditText
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="30dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:textSize="14sp"
            android:background="@drawable/stylebutton"/>
        <ImageView
            android:id="@+id/main_region_btn"
            android:layout_marginLeft="10dp"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:background="@drawable/arrow"/>
    </LinearLayout>
    <!--内容开始-->
    <ScrollView
        android:layout_below="@id/topSearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        ...
        ...
        ...
        ...
        ...
        ...
    </ScrollView>
</RelativeLayout>



 浏览器启用弹出窗口过滤功能,将无法跳转到下载页。在浏览器地址栏右边符号提示处点击允许就可以了!

转载请注明来源地址:小川编程 » https://www.youhutong.com/index.php/article/index/178.html


  1、本站发布的内容仅限用于学习和研究目的.请勿用于商业或非法用途,下载后请24小时内删除。
  2、本站所有内容均不能保证其完整性,不能接受请勿购买或下载,如需完整程序,请去其官方购买正版使用
  3、本站联系方式Email:admin@youhutong.com ,收到邮件会第一时间处理。
  4、如侵犯到任何版权问题,请立即告知本站(立即在线告知),本站将及时删除并致以最深的歉意
( 0 )个小伙伴在吐槽
    登录帐号  如果已经登录请刷新! 发表我的评论
    表情