Android 同时使用scrollview和adjustPan
我在舱单上写了Android 同时使用scrollview和adjustPan,android,android-manifest,Android,Android Manifest,我在舱单上写了 <activity android:name=".email" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"> </activity> 在我的布局中,我写了 &
<activity android:name=".email"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan">
</activity>
在我的布局中,我写了
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white" >
<ImageView
android:id="@+id/bottomImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/ic_backdrop_wave" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:isScrollContainer="false" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText>
</EditText>
<EditText>
</EditText>
<EditText>
</EditText>
</LinearLayout>
</ScrollView>
因此,当我点击任何编辑文本时,它不会重新调整imageview的大小,但也会禁用scroll view
现在我要做的是,我想要这样的布局:当任何软键盘打开时,图像视图的高度不会改变,它将保持与父底部对齐,当软键板打开时,滚动视图处于启用状态。您尝试过使用
android:WindowsOfInputMode=“调整大小”
这不会调整imageview的大小,而是在键盘弹出时自动调整屏幕
确保您的图像位于滚动视图中的单个子视图中,并与底部对齐,如下所示
<ScrollView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
android:layout_height="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
....
....
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bottom_illustration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/some_text_view"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="@drawable/login_illustration" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
将其添加到AndroidManifest.xml中的活动标记下
android:windowSoftInputMode="adjustResize"
是的,我试过了,但图像视图设置在软键盘上方,我不想将其设置在键盘上方,我希望它在任何情况下都与ParentBottom对齐,是否可能?如果软键盘打开,我想设置图像视图与ParentBottom对齐,并且当键盘打开时,我的布局可以滚动。我已经设置了android:WindowsOfInputMode=“adjustPan”,所以如果软键盘打开但布局不可滚动,我的图像视图将设置为底部。我以前也遇到过类似问题。我认为adjustPan和scrollview不能同时工作。但如果视图数量超过屏幕高度,则它将滚动。如果我得到答案,我会发布答案。我很久以前就知道这个问题了,但我想知道这个问题的作者现在是否找到了解决办法?现在我也遇到了同样的问题,我在android 2.2上工作,遇到了scrollview和软键盘的adjustpan问题。当软键盘以adjustpan模式显示时,我无法将布局向下滚动。如果你已经解决了这个问题,请帮我一个忙:在这个线程上发布你的解决方法。我很感激,这里也一样。使用adjustResize可以将滚动视图滚动到底部,但可以调整顶部按钮的大小。使用adjustPan将按钮的高度保留在顶部,但不允许滚动到底部。
android:windowSoftInputMode="adjustResize"