android - 启用调整大小或滚动键盘弹出的 Activity

标签 android android-layout

我已经看到许多关于如何禁用滚动 Activity 文本字段的标准 Android 行为或在弹出屏幕键盘时调整当前 Activity 大小的帖子,但我的问题恰恰相反。我的应用程序既没有滚动也没有调整大小。

我必须做什么才能实现正确的行为?

<?xml version="1.0" encoding="utf-8"?>

<!-- The main content view -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RootView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?colorPrimary">

    <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/slidingPanel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        sothree:umanoFadeColor="@android:color/transparent"
        sothree:umanoOverlay="true"
        sothree:umanoPanelHeight="200dp"
        sothree:umanoShadowHeight="0dp">

        <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:id="@+id/fragmentContainer"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/scrollView1"
                android:layout_width="@dimen/lewa_lista_size"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:background="?xenoPanelBackgroundColor"/>
        </android.support.v4.widget.DrawerLayout>

        <RelativeLayout
            android:id="@+id/playlist"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center">

            <LinearLayout
                android:id="@+id/chwytak"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/tlo_kropek"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/kropki"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/uchwyt_szuflady_height"
                    android:layout_centerHorizontal="true"
                    android:gravity="center_horizontal"
                    android:src="@mipmap/kropki" />

                <RelativeLayout
                    android:id="@+id/wypelniaczGorny"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"/>
            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/playlistAB"
                style="?xenoActionBarTheme"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/chwytak"
                android:elevation="4dp"
                android:minHeight="?attr/actionBarSize">

                <Spinner
                    android:id="@+id/spinner_toolbar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.Toolbar>

            <RelativeLayout
                android:id="@+id/wypelniacz"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_alignParentBottom="true"
                android:background="?xenoPanelBackgroundColor"/>

            <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_above="@id/wypelniacz"
                android:layout_below="@id/playlistAB"
                android:background="?xenoPanelBackgroundColor"/>
        </RelativeLayout>
    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</FrameLayout>

最佳答案

您可以在 list 中使用 windowSoftInputMode 属性作为示例

 <activity
    android:windowSoftInputMode="adjustPan"
    android:name=".YourActivity"></activity>

Activity 的主窗口如何与包含屏幕软键盘的窗口交互。此属性的设置会影响两件事: 当 Activity 成为用户关注的焦点时,软键盘的状态——无论是隐藏还是可见。 对 Activity 的主窗口所做的调整 — 是否将其调整得更小以便为软键盘腾出空间,或者当窗口的一部分被软键盘覆盖时是否平移其内容以使当前焦点可见。

在这里您可以获得更多信息 https://developer.android.com/guide/topics/manifest/activity-element.html

您可以根据自己的需求获取合适的属性

关于android - 启用调整大小或滚动键盘弹出的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43865963/

相关文章:

eclipse - 有没有办法在eclipse中生成 "Lorem ipsum"?

android - 从主题中获取 EditText 的 'default' 颜色值

android - 如何在 ViewHolder 上设置 setOnClickListner 并使用 Intent 启动一个新的 Activity?

java - Android ffmpeg concat 两个视频声音错误

android - 让 picasso 在行可见之前加载图像

android - 设置抽屉导航图标的背景

java - 如何将图像加载到不在 Activity 布局中的 imageView 中?

android - 显示错误的 ArrayAdapter 无法解决构造函数适配器错误

java - java中如何保存持久化数据

android - 为什么 Android SDK Manager 只显示默认包?