首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将滚动视图和adjustPan结合使用

将滚动视图和adjustPan结合使用
EN

Stack Overflow用户
提问于 2011-07-29 03:42:10
回答 2查看 5.3K关注 0票数 4

在我的名单上我写了

代码语言:javascript
复制
 <activity android:name=".email" 
           android:label="@string/app_name"
           android:theme="@android:style/Theme.NoTitleBar"
           android:windowSoftInputMode="adjustPan">         
 </activity>

在我的版面上我写了

代码语言:javascript
复制
    <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>

因此,当我单击任何编辑文本时,它不会重新调整图像视图的大小,但它也将禁用滚动视图。

现在我要做的是,我想要这样的布局,在这种布局中,图像视图的高度不会改变,当任何软键盘打开时,它将坚持对齐父底部,而滚动视图是启用的,而软键盘是打开的。

EN

回答 2

Stack Overflow用户

发布于 2011-07-29 04:31:36

你试过用

android:windowSoftInputMode="adjustResize“

这不会调整图像视图的大小,而是在键盘弹出时自动调整屏幕。

票数 2
EN

Stack Overflow用户

发布于 2020-03-04 14:16:18

这是解决办法。

确保您的图像在ScrollView中的单个子图中,它对齐到底部,如下所示。

代码语言:javascript
复制
<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>

ScrollView添加下列属性

代码语言:javascript
复制
android:fillViewport="true"
android:isScrollContainer="true"

将此添加到AndroidManifest.xml中的活动标记下

代码语言:javascript
复制
android:windowSoftInputMode="adjustResize"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6868404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档