【发布时间】:2015-10-30 12:19:53
【问题描述】:
我有一些元素的滚动视图,其中之一 - 编辑文本,靠近布局的底部。 当此editText 通过单击请求焦点时 - 打开软键盘并覆盖该editText 字段,因此用户无法看到他输入的内容...
任何想法为什么会发生以及如何解决它?
这是我的代码清单:
<activity
android:name=".acitivity.TransferActivity"
android:label="@string/title_activity_transfer"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
这里是活动 xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_transfer"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container_transfer_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_transfer" />
</LinearLayout>
这里是片段 xml:
<ScrollView
android:id="@+id/transfer_scroller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blue_500"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
//some code here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
//some code here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/et_transfer_p1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:inputType="number"
android:textColor="@color/gray_400"
android:textSize="@dimen/font_main_2" >
</EditText>
</LinearLayout>
</LinearLayout>
</ScrollView>
【问题讨论】:
-
也许你在你的styles.xml中为你的
Activity设置了android:windowTranslucentStatus=true。请添加您的styles.xml。 -
在清单中尝试使用 android:windowSoftInputMode="adjustPan"
-
看看这里developer.android.com/guide/topics/manifest/… -- 你可能需要添加(adjustUnspecified)
标签: android android-edittext android-softkeyboard android-scrollview