弹出窗口中的EditText:键盘未显示

时间:2017-09-26 19:18:00

标签: android android-edittext android-softkeyboard

我已经为一个调查创建了一个弹出窗口的布局,但是当焦点为真时,即使在点击编辑文本后,键盘也不会显示...

在其他活动中,所有EditTexts都能正常工作。

最近,我已将app Theme更改为AppCompat以实现Material组件。我不确定它会产生什么影响,但是我没有想法,为什么它不起作用。

有什么想法吗?

enter image description here

<?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"
    android:background="#66ccff"
    android:gravity="center" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageSurveyClose"
        android:layout_centerHorizontal="true"
        android:paddingTop="40dp"
        android:fontFamily="sans-serif"          
        android:gravity="center"    
        android:text="Question"
        android:textColor="#ffffff"
        android:textSize="22dp" />

    <ImageButton
        android:id="@+id/imageSurveyClose"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/close"
        android:background="@null" />

        <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Send" />

        <RadioGroup
            android:id="@+id/radioGroup2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/textView1"
            android:paddingTop="20dp"
            android:layout_marginLeft="20dp"
            >

            <RadioButton
                android:id="@+id/radio0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="v1"                
                android:layout_gravity="left"
                android:fontFamily="sans-serif"
                android:textSize="22dp"
                android:buttonTint="#ffffff"  
                android:textColor="#ffffff"
                android:layout_marginTop="10dp"             
                />

            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left"               
                android:fontFamily="sans-serif"                
                android:text="v2"
                android:buttonTint="#ffffff"
                android:layout_marginTop="12dp"
                android:textColor="#ffffff"
                android:textSize="22dp" />

            <RadioButton
                android:id="@+id/radio2"
                android:layout_width="wrap_content"
                android:buttonTint="#ffffff"
                android:layout_height="wrap_content"
                android:text="v3"                               
                android:layout_gravity="left"
                android:fontFamily="sans-serif"
                android:layout_marginTop="12dp"
                android:textSize="22dp"
                android:textColor="#ffffff"
                 />
        </RadioGroup>

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/radioGroup2"
            android:layout_below="@+id/radioGroup2"
            android:layout_marginTop="47dp"                        
            android:ems="10" >

            <requestFocus />
        </EditText>

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

您可以尝试删除EditText中的&lt; requestFocus /&gt; 元素,看看键盘是否出现。之后,您可以在活动中以编程方式请求焦点。