1

I work on a background for my app but when i open the keyboard the image resizes.

I have heard from adjustPan and so on but it doesn´t work to. getWindow.setBackground also don´t work because i am on a fragment.

If i set the Windows Background it works , but when i go back the background is still there.
Screens:
Correct screen
Incorrect screen

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

0

The reason seems to be that you're using android:windowSoftInputMode="adjustResize" which resizes your activity when the soft keyboard is opened. This is what you want for sure, but background images are always resized to fit the entire element. Instead of using a background, place an ImageView in the bottom of the layout and put the image there with a proper android:scaleType, this prevents the aspect ratio from being lost.

etan
  • 573
  • 5
  • 14
0

Add ImageView with scaleType="fitStart"

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="280dp"
             android:layout_height="match_parent"
             android:background="@android:color/white"
             android:paddingTop="8dp">

    <ImageView
        android:id="@+id/img_background"
        android:src="@drawable/background"
        android:scaleType="fitStart"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


    <include layout="@layout/content"/>

</FrameLayout>
Marlen
  • 146
  • 8