我在带有 textView、Button 和 ImageView 的 Fragment 中使用 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>
请有人帮我解决我的问题
最佳答案
虽然现在回复这个帖子已经很晚了。我遇到了同样的问题并用
解决了window.setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
)
我根据屏幕要求动态设置了这个标志。
关于当键盘出现在 Fragment 中时,Android EditText 键入的文本不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39836296/