Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 背景图像在键盘弹出窗口上缩小_Android_Image_Scrollview_Drawable_Window Soft Input Mode - Fatal编程技术网

Android 背景图像在键盘弹出窗口上缩小

Android 背景图像在键盘弹出窗口上缩小,android,image,scrollview,drawable,window-soft-input-mode,Android,Image,Scrollview,Drawable,Window Soft Input Mode,我有一个带有背景图像的父布局,所以在添加滚动视图后,当键盘弹出时,背景图像会缩小 如下图所示: 我检查了所有的解决方案,添加了windowSofInput作为adjustResize和adjustPan,但adjustResize解决了问题,通过使用adjustPan无法向上滚动页面,滚动视图dosent使用adjustPan工作 我尝试添加滚动视图的一些属性,如fillViewPort、adjustViewBounds和true 我也试过了 真的 使用此滚动视图不会收缩,但我不需要全屏,状

我有一个带有背景图像的父布局,所以在添加滚动视图后,当键盘弹出时,背景图像会缩小

如下图所示:

我检查了所有的解决方案,添加了windowSofInput作为adjustResize和adjustPan,但adjustResize解决了问题,通过使用adjustPan无法向上滚动页面,滚动视图dosent使用adjustPan工作

我尝试添加滚动视图的一些属性,如fillViewPort、adjustViewBounds和true

我也试过了 真的 使用此滚动视图不会收缩,但我不需要全屏,状态栏不能全屏显示

我尝试添加图像视图,而不是将背景图像设置到父布局,并尝试设置其缩放类型,矩阵缩放类型dosent shrink,但我的背景图像与原始图像不一样

看起来像是:

布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="matrix"
        android:src="@drawable/page"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bg_color"
        android:alpha="0.5"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds = "true"
        android:isScrollContainer="true"
        android:fillViewport="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver"><!--

  <ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:src="@drawable/page"
      android:scaleType="fitXY"/>
-->


        <RelativeLayout
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_marginEnd="@dimen/dimen_10dp"
            android:layout_marginStart="@dimen/dimen_10dp"
            android:layout_marginLeft="@dimen/dimen_10dp"
            android:layout_marginRight="@dimen/dimen_10dp">

            <ImageView
                android:id="@+id/logo"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="@dimen/dimen_20dp"
                android:src="@drawable/petrolpump" />

            <TextView
                android:id="@+id/register_driver_welcome"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_below="@+id/logo"
                android:layout_marginTop="@dimen/dimen_15dp"
                android:padding="@dimen/dimen_10dp"
                android:text="@string/welcome_driver"
                android:textColor="@color/divider_color"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/edt_mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/register_driver_welcome"
                android:drawableLeft="@drawable/ic_local_phone"
                android:hint="Mobile No."
                android:inputType="number"
                android:maxLength="10"
                android:maxLines="1"
                android:padding="@dimen/dimen_15dp"
                android:textColor="@color/divider_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/dimen_15dp" />

            <TextView
                android:id="@+id/register_driver_enter"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_below="@+id/edt_mobile"
                android:padding="@dimen/dimen_10dp"
                android:text="@string/otp_send"
                android:textColor="@color/divider_color"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/register_driver_otp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/register_driver_enter"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                android:layout_marginTop="@dimen/dimen_5dp"
                android:drawableLeft="@drawable/ic_lock_close"
                android:hint="OTP"
                android:inputType="number"
                android:maxLength="4"
                android:maxLines="1"
                android:padding="@dimen/dimen_15dp"
                android:textColor="@color/divider_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/dimen_15dp" />


            <Button
                android:id="@+id/register_driver_register"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/register_driver_otp"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="@dimen/dimen_20dp"
                android:layout_marginTop="20dp"
                android:background="@color/colorPrimary"
                android:text="Register"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/register_driver_sendotp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/edt_mobile"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="@dimen/dimen_40dp"
                android:layout_marginTop="20dp"
                android:background="@color/colorPrimary"
                android:text="Send OTP"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/btn_resend"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/register_driver_register"
                android:layout_below="@+id/register_driver_otp"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="@dimen/dimen_20dp"
                android:layout_marginTop="20dp"
                android:background="@color/colorPrimary"
                android:text="RESEND OTP"
                android:textColor="@android:color/white"
                android:visibility="gone" />
        </RelativeLayout>
    </RelativeLayout>
    </ScrollView>
</RelativeLayout>


有人能帮我吗?谢谢。

不要用xml设置背景。将活动中的图像设置为窗口背景

getWindow().setBackgroundDrawableResource(R.drawable.bg);
和舱单条目

<activity
        android:name=".ActivityName"
        android:configChanges="screenSize|keyboard|orientation|screenSize"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden" />

如果要设置背景图像,应在父relativelayout上进行设置,而不是使用imageview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/page"
tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_color"
    android:alpha="0.5"/>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds = "true"
    android:isScrollContainer="true"
    android:fillViewport="true">

.....

.....

请发布您的布局xmlyes added请检查@naz141这可能有帮助:(使用框架布局并首先添加图像视图)。。还有一个原因是为什么你将你的相对布局嵌套在另一个相对布局中(滚动视图->相对布局->相对布局)?是的,但这并没有帮助它仍然会缩小@Jasonsaruulo这是有效的。。但是一些图像隐藏在appbar下面,因为它被设置为窗口屏幕@是的,那是因为它设置为窗口。如果您使用的是AppBar,那么您可以将xml中的Linearlayout用作清单中android:WindowsOfInputMode=“adjustNothing”的根目录。我发送此解决方案是因为您附加的图像不显示任何AppBar。我无法使用线性布局,我已将视图根据相对布局设置为父视图。我试图给relative添加任何内容,但没有成功。您的布局似乎并不复杂,但很简单。如果放置线性布局可以解决问题,那么只需将其添加为根父布局。好的,我尝试了,但没有解决问题,图像仍在应用程序栏后面。