为什么edittext隐藏在软键盘后面
Why edittext is hide behinde softkeyboard
我有一张 ScrollView
的图片和一个滚动视图中的多个编辑文本,但是当单击一个 EditText
并打开键盘时,该图片视图的大小已更改,我不想更改大小为此,我在清单中将 android:windowSoftInputMode="adjustResize|adjustPan|stateVisible"
添加到我的 activity,但现在当键盘打开且滚动视图未滚动到最后时,最后一个 EditText
隐藏在键盘后面。
xml :
`
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_without_elevation" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@color/primary_color"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.3" />
<com.balysv.materialripple.MaterialRippleLayout
android:id="@+id/rippleChangeProfileImage"
style="@style/ImageViewRipple"
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imgProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_margin="@dimen/size_8_dp"
android:background="@drawable/ic_add_a_photo_white_48dp"
android:onClick="changeContactPhoto"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp" />
</com.balysv.materialripple.MaterialRippleLayout>
<TextView
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.3" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.75"
android:fillViewport="true"
android:isScrollContainer="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--android:layout_weight="1"-->
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10_dp"
android:gravity="center"
android:orientation="vertical">
<!--android:layout_marginTop="@dimen/size_10_dp"-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/linearName"
style="@style/ProfileLinearLayout"
android:layout_marginBottom="@dimen/size_5_dp">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/edtName"
style="@style/profileDialogEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_16_dp"
android:layout_marginRight="@dimen/size_16_dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="@dimen/size_10_dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/Profile_text_color"
android:textSize="@dimen/size_12_sp"
app:met_floatingLabel="normal"
android:windowSoftInputMode="adjustResize" />
<ImageView
android:id="@+id/imgName"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginRight="16dp"
android:layout_marginTop="@dimen/size_15_dp"
android:src="@drawable/ic_person_outline_white_24dp" />
</LinearLayout>
<ImageView
android:id="@+id/imageView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5_dp"
android:src="@drawable/item_separator_as_line" />
//several EditText Like This
</LinearLayout>
`
将此添加到您的 <activity>
:
android:windowSoftInputMode="adjustPan"
或:
android:windowSoftInputMode="adjustResize"
像这样:
<activity
android:name="com.my.MainActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_main"
android:windowSoftInputMode="stateVisible|adjustResize" >
</activity>
尝试从应该有效的主线性布局中移除重量;
并将屏幕宽度或高度设置为 linearLayout
我有一张 ScrollView
的图片和一个滚动视图中的多个编辑文本,但是当单击一个 EditText
并打开键盘时,该图片视图的大小已更改,我不想更改大小为此,我在清单中将 android:windowSoftInputMode="adjustResize|adjustPan|stateVisible"
添加到我的 activity,但现在当键盘打开且滚动视图未滚动到最后时,最后一个 EditText
隐藏在键盘后面。
xml :
`
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_without_elevation" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@color/primary_color"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.3" />
<com.balysv.materialripple.MaterialRippleLayout
android:id="@+id/rippleChangeProfileImage"
style="@style/ImageViewRipple"
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imgProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_margin="@dimen/size_8_dp"
android:background="@drawable/ic_add_a_photo_white_48dp"
android:onClick="changeContactPhoto"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp" />
</com.balysv.materialripple.MaterialRippleLayout>
<TextView
android:layout_width="@dimen/size_0_dp"
android:layout_height="match_parent"
android:layout_weight="0.3" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.75"
android:fillViewport="true"
android:isScrollContainer="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--android:layout_weight="1"-->
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10_dp"
android:gravity="center"
android:orientation="vertical">
<!--android:layout_marginTop="@dimen/size_10_dp"-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/linearName"
style="@style/ProfileLinearLayout"
android:layout_marginBottom="@dimen/size_5_dp">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/edtName"
style="@style/profileDialogEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_16_dp"
android:layout_marginRight="@dimen/size_16_dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="@dimen/size_10_dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/Profile_text_color"
android:textSize="@dimen/size_12_sp"
app:met_floatingLabel="normal"
android:windowSoftInputMode="adjustResize" />
<ImageView
android:id="@+id/imgName"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginRight="16dp"
android:layout_marginTop="@dimen/size_15_dp"
android:src="@drawable/ic_person_outline_white_24dp" />
</LinearLayout>
<ImageView
android:id="@+id/imageView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5_dp"
android:src="@drawable/item_separator_as_line" />
//several EditText Like This
</LinearLayout>
`
将此添加到您的 <activity>
:
android:windowSoftInputMode="adjustPan"
或:
android:windowSoftInputMode="adjustResize"
像这样:
<activity
android:name="com.my.MainActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_main"
android:windowSoftInputMode="stateVisible|adjustResize" >
</activity>
尝试从应该有效的主线性布局中移除重量; 并将屏幕宽度或高度设置为 linearLayout