键盘出现在Fragment中时,Android EditText键入的文本未显示

时间:2016-10-03 16:33:26

标签: android android-fragments android-edittext

我在Fragment中使用带有textView,Button和ImageView的EditText。

我的问题是:

当键盘出现时,我无法看到输入的内容。

我的XML代码是:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/background_light"
        android:clickable="true">

        <!-- TODO: Update blank fragment layout -->

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="5dp">

            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">

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

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="190dp"
                        android:background="@drawable/header" />

                    <TextView
                        android:id="@+id/head"
                        style="@style/Base.TextAppearance.AppCompat.Large"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="sub heading" />

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/request_til"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <EditText
                            android:id="@+id/request_et"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="Enter your Name and Address here"
                            android:maxLines="10"
                            android:minLines="6" />
                    </android.support.design.widget.TextInputLayout>
                </LinearLayout>

            </ScrollView>

            <Button
                android:id="@+id/request_btn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:background="@color/colorPrimary"
                android:text="Button"
                android:textColor="@android:color/background_light" />
        </RelativeLayout>
    </FrameLayout>

ScreenShots: 键盘出现时:我无法看到即时打字 enter image description here

键入后键盘消失只有那时我才能看到输入的内容: enter image description here

请有人帮我解决我的问题

3 个答案:

答案 0 :(得分:1)

使用RelativeLayout而不是FrameLayout,你不需要ScrollView的父视图组我觉得它应该适用于她们我们去

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light"
    android:clickable="true">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp">

                <ImageView
                    android:id="@+id/img"
                    android:layout_width="match_parent"
                    android:layout_height="190dp"
                    android:background="@drawable/header" />

                <TextView
                    android:id="@+id/head"
                    style="@style/Base.TextAppearance.AppCompat.Large"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="sub heading"
                    android:layout_below="@+id/img" />

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/request_til"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/head">

                    <EditText
                        android:id="@+id/request_et"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Enter your Name and Address here"
                        android:maxLines="10"
                        android:minLines="6" />
                </android.support.design.widget.TextInputLayout>
            </RelativeLayout>

        </ScrollView>

        <Button
            android:id="@+id/request_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/colorPrimary"
            android:text="Button"
            android:textColor="@android:color/background_light"
            android:layout_gravity="bottom"/>

</RelativeLayout>

答案 1 :(得分:1)

尽管回复此帖子为时已晚。我遇到了同样的问题,并用

解决了
window.setFlags(
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
)

我根据屏幕要求动态设置此标志。

答案 2 :(得分:0)

include('./vendor/autoload.php');
include('./config.php');
include('./randos.php');

use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants;
use Twilio\Jwt\Grants\VoiceGrant;
use Twilio\Rest\Client;

// choose a random username for the connecting user
$identity = randomUsername();


$token = new AccessToken($TWILIO_ACCOUNT_SID, $API_KEY, $API_KEY_SECRET, 3600, $identity);

$grant = new VoiceGrant();
$grant->setPushCredentialSid($PUSH_CREDENTIAL_SID);
$grant->setOutgoingApplicationSid($TWILIO_TWIML_APP_SID);
$token->addGrant($grant);

echo $token;