ScrollView中EditText无法获取焦点

时间:2022-11-17 22:37:18
自定义ScrollView中嵌套了EditText和自定义的ListView  但是EditText不能获取焦点  如何解决

贴上布局代码

<com.yifang.house.widget.pullrefresh.PullToRefreshScrollView
            xmlns:ptr="http://schemas.android.com/apk/res-auto"
            android:id="@+id/pull_refresh_scrollview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none"
            ptr:ptrAnimationStyle="flip"
            ptr:ptrMode="both" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#EEEEEE"
                android:orientation="vertical" >

                <RelativeLayout
                    android:id="@+id/rel_search"
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/dimen_30_dip"
                    android:layout_marginBottom="@dimen/dimen_10_dip"
                    android:layout_marginLeft="@dimen/dimen_20_dip"
                    android:layout_marginRight="@dimen/dimen_20_dip"
                    android:layout_marginTop="@dimen/dimen_10_dip"
                    android:background="@drawable/white_boarder"
                    android:focusable="true"
                    android:focusableInTouchMode="true" >

                    <RelativeLayout
                        android:id="@+id/search_rl"
                        android:layout_width="@dimen/dimen_28_dip"
                        android:layout_height="@dimen/dimen_28_dip"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true" >

                        <ImageView
                            android:id="@+id/search_iv"
                            android:layout_width="@dimen/dimen_18_dip"
                            android:layout_height="@dimen/dimen_15_dip"
                            android:layout_centerVertical="true"
                            android:layout_marginRight="@dimen/dimen_10_dip"
                            android:src="@drawable/search" />
                    </RelativeLayout>

                    <EditText
                        android:id="@+id/key_et"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:focusable="true"
                        android:layout_toLeftOf="@+id/search_rl"
                        android:background="@null"
                        android:hint="请输入关键字"
                        android:maxLength="10"
                        android:paddingLeft="@dimen/dimen_5_dip"
                        android:singleLine="true"
                        android:textColor="@color/ablack"
                        android:textCursorDrawable="@null"
                        android:textSize="@dimen/dimen_14_sp" />
                </RelativeLayout>

                <com.yifang.house.widget.MyListView
                    xmlns:ptr="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/house_list_lv"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:cacheColorHint="#00000000"
                    android:background="@color/white"
                    android:listSelector="#00000000"
                    android:scrollbars="none"
                    ptr:ptrMode="both" />
        

            </LinearLayout>
        </com.yifang.house.widget.pullrefresh.PullToRefreshScrollView>

6 个解决方案

#1


android:textColor="@color/ablack"

怎么有个ablack这样的?看是否颜色设置的有问题,有时候光标可能和背景色一样了,而且输入文字和背景色也一样造成看不见,其实是输入了的,你测试一下看看是否输入了,改变下背景颜色看看,或者用getText看看到底有没有输入或者是否有焦点

#2


引用 1 楼 Perfect411_111 的回复:
android:textColor="@color/ablack"

怎么有个ablack这样的?看是否颜色设置的有问题,有时候光标可能和背景色一样了,而且输入文字和背景色也一样造成看不见,其实是输入了的,你测试一下看看是否输入了,改变下背景颜色看看,或者用getText看看到底有没有输入或者是否有焦点


很确定是没有获取到焦点  点击键盘都弹不出

#3


遍历一下控件,看看焦点在谁那再分析

#4


引用 3 楼 BEYONDMA 的回复:
遍历一下控件,看看焦点在谁那再分析


怎么遍历看焦点。。。

#5


那估计是被某个控件把焦点抢夺了

#6


撸主解决没?

#1


android:textColor="@color/ablack"

怎么有个ablack这样的?看是否颜色设置的有问题,有时候光标可能和背景色一样了,而且输入文字和背景色也一样造成看不见,其实是输入了的,你测试一下看看是否输入了,改变下背景颜色看看,或者用getText看看到底有没有输入或者是否有焦点

#2


引用 1 楼 Perfect411_111 的回复:
android:textColor="@color/ablack"

怎么有个ablack这样的?看是否颜色设置的有问题,有时候光标可能和背景色一样了,而且输入文字和背景色也一样造成看不见,其实是输入了的,你测试一下看看是否输入了,改变下背景颜色看看,或者用getText看看到底有没有输入或者是否有焦点


很确定是没有获取到焦点  点击键盘都弹不出

#3


遍历一下控件,看看焦点在谁那再分析

#4


引用 3 楼 BEYONDMA 的回复:
遍历一下控件,看看焦点在谁那再分析


怎么遍历看焦点。。。

#5


那估计是被某个控件把焦点抢夺了

#6


撸主解决没?