美文网首页知识点
EditText在底部输入被遮挡问题

EditText在底部输入被遮挡问题

作者: 糖葫芦_倩倩 | 来源:发表于2017-02-15 10:17 被阅读42次

    在这次项目开发中,遇到一个特别长的页面,刚好输入框 EditText在底部,点击输入,根本看不见输入框在哪里,外面是 scrollview,页面也滚动。

    首先这是我原先的代码:

    <EditText
                        android:id="@+id/tv_baoe_str"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toLeftOf="@+id/arrow4"
                        android:hint="请输入"
                        android:layout_alignParentRight="true"
                        android:background="@android:color/transparent"
                        android:textColor="@color/calulator_Weight"
                        android:textSize="@dimen/text_h16" />
    

    我的background直接设置成透明的。结果就出现上述的问题。

    解决方案:
    <1>把背景设置drawable. shape_et_bg

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

    然后editText再引进去。

     <EditText
                        android:layout_toRightOf="@id/tv_baoe"
                        android:id="@+id/tv_baoe_str"
                        android:gravity="right|center_vertical"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_centerVertical="true"
                        
                        android:layout_toLeftOf="@+id/arrow4"
                        android:hint="请输入"
                        android:layout_alignParentRight="true"
                        android:background="@drawable/shape_et_bg"
                        android:textColor="@color/calulator_Weight"
                        android:textSize="@dimen/text_h16" />
    

    最后输入框就不会被遮挡了。

    相关文章

      网友评论

      • 296d6ebc6cd2:原理是啥
      • 埃赛尔:是因为背景的关系才会遮挡嘛?
        糖葫芦_倩倩:不是 我的意思是你可以通过设置背景来解决这个问题;还有就是恰当使用 fitsystem 属性也可以解决问题

      本文标题:EditText在底部输入被遮挡问题

      本文链接:https://www.haomeiwen.com/subject/kwzovttx.html