Good morning everyone!
I'm working on a game for Android, which has a EditText
numeric type. By touching it, the keyboard is displayed, and in doing so, it modifies the size of my layout parent, which is a RelativeLayout
.
The problem is that it is assigned to the property android:background
an image .png and this is scaled to the size of RelativeLayout
and does not look good.
Is there any way this does not happen?
I add the .xml as a guide, although it's a bit long:
<?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:id="@+id/juego"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
tools:context="derivadadx.juegodelnumero.Juego"
android:background="@drawable/fondo">
<EditText
android:id="@+id/numInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:ems="10"
android:inputType="number"
android:hint="@string/numInput"
android:textColorHint="@color/negro"
android:gravity="center"
android:background="@drawable/borde_rojo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:imeOptions="actionDone"/>
<Button
android:id="@+id/verificar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/numInput"
android:layout_marginTop="@dimen/separacion_elementos"
android:text="@string/verificar"
android:background="@drawable/boton_negro"/>
<LinearLayout
android:id="@+id/columnas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/verificar"
android:layout_marginTop="@dimen/separacion_elementos"
android:background="@drawable/borde_verde">
<TextView
style="@style/AreaDeResultados"
android:text="@string/columna_numero"/>
<TextView
style="@style/AreaDeResultados"
android:text="@string/columna_aciertos"/>
<TextView
style="@style/AreaDeResultados"
android:text="@string/columna_regular"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/columnas"
android:layout_centerHorizontal="true"
android:layout_marginTop="2dp"
android:background="@drawable/borde_azul">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/numeros"
style="@style/AreaDeResultados"/>
<TextView
android:id="@+id/aciertos"
style="@style/AreaDeResultados"/>
<TextView
android:id="@+id/regulares"
style="@style/AreaDeResultados"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
And when you hit the EditText
field, this is what happens:
There you can see how he modifies the ScrollView
and other elements within the RelativeLayout
, which is not the problem, but modifies the image of background
of it.