How to make elements stable in differens emulators? - android

Here is the form that I made in the XML:
Here the output when I run it on an emulator:
Does any one know how to make the emulator have the same style as the XML page?
I'm using nexus 6 emulator and the following. Is my XML code. I have added in manifest part a support element, but I still have the problem.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".signupActivity"
android:background="#color/white">
<EditText
android:id="#+id/input_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="138dp"
android:backgroundTint="#D3D3D3"
android:fontFamily="sans-serif"
android:hint="Name"
android:textColor="#7c7a7a"
android:textColorHint="#A9A9A9" />
<!-- email text field -->
<EditText
android:id="#+id/input_email"
android:layout_width="306dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="201dp"
android:backgroundTint="#D3D3D3"
android:fontFamily="sans-serif"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#7c7a7a"
android:textColorHint="#A9A9A9" />
<!-- phone text field -->
<EditText
android:id="#+id/phoneNO"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="141dp"
android:backgroundTint="#D3D3D3"
android:fontFamily="sans-serif"
android:hint="phone number"
android:inputType="phone"
android:textColor="#7c7a7a"
android:textColorHint="#A9A9A9" />
<EditText
android:id="#+id/input_password"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:backgroundTint="#D3D3D3"
android:fontFamily="sans-serif"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#7c7a7a"
android:textColorHint="#A9A9A9" />
<!-- login block -->
<TextView
android:id="#+id/link_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="22dp"
android:layout_weight="1"
android:gravity="center"
android:text="Already a member? Login"
android:textColor="#6F73FF"
android:textSize="16dip" />
<!-- password text field -->
<EditText
android:id="#+id/input_password2"
android:layout_width="302dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="202dp"
android:backgroundTint="#D3D3D3"
android:fontFamily="sans-serif"
android:hint="confirm password"
android:inputType="textPassword"
android:textColor="#7c7a7a"
android:textColorHint="#A9A9A9" />
<!-- Signup Button -->
<Button
android:id="#+id/btn_signup"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="64dp"
android:background="#drawable/edit_rouded"
android:fontFamily="sans-serif"
android:padding="12dp"
android:text="Create Account" />
<ProgressBar
android:id="#+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="73dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#6F73FF"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp"
android:text="Sign Up"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="24sp" />
<ImageView
android:layout_width="30dp"
android:layout_height="38dp"
android:layout_alignBottom="#+id/phoneNO"
android:layout_toStartOf="#+id/input_name"
android:adjustViewBounds="false"
android:src="#drawable/ic_call_black_24dp"
tools:layout_editor_absoluteX="20dp"
tools:layout_editor_absoluteY="267dp" />
<ImageView
android:layout_width="30dp"
android:layout_height="38dp"
android:layout_alignTop="#+id/input_password2"
android:layout_toStartOf="#+id/input_name"
android:adjustViewBounds="false"
android:src="#drawable/ic_lock_outline_black_24dp"
tools:layout_editor_absoluteX="20dp"
tools:layout_editor_absoluteY="267dp" />
<ImageView
android:layout_width="30dp"
android:layout_height="38dp"
android:layout_alignTop="#+id/input_password"
android:layout_toStartOf="#+id/input_name"
android:adjustViewBounds="false"
android:src="#drawable/ic_lock_outline_black_24dp"
tools:layout_editor_absoluteX="20dp"
tools:layout_editor_absoluteY="267dp" />
<ImageView
android:layout_width="30dp"
android:layout_height="43dp"
android:layout_alignTop="#+id/input_email"
android:layout_toStartOf="#+id/input_name"
android:adjustViewBounds="false"
android:src="#drawable/ic_mail_outline_black_24dp"
tools:layout_editor_absoluteX="20dp"
tools:layout_editor_absoluteY="267dp" />
<ImageView
android:layout_width="30dp"
android:layout_height="38dp"
android:layout_alignBottom="#+id/input_name"
android:layout_toStartOf="#+id/input_name"
android:adjustViewBounds="false"
android:src="#drawable/ic_perm_identity_black_24dp"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="267dp" />
</RelativeLayout>
I have changed the layout from absolute to relative but I still have the problem.

You are setting up the elements by placing margins. this will not work perfectly on all devices. Rather please use appropriate layout and implement the design
Ex: Create a linear layout with a vertical orientation and add the elements. This will scale with all kinds of screens. Additionally, keep the main layout inside a scroll view. this will help in very small screens

Related

AndroidStudio Problem with Relative Layout

I have a problem with RelativeLayout. In design view I can see my Layout works perfect, but in runtime one EditText goes down from the screen.
Here is some code of my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvInicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:text="#string/dialog_titulo"
android:textColor="#color/colorPrimary"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvPrimero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="85dp"
android:text="#string/dialog_max"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etMaximo"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tvPrimero"
android:layout_alignParentEnd="true"
android:ems="10"
android:hint="#string/dialog_etMax"
android:inputType="number"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/etMinimo"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="151dp"
android:ems="10"
android:hint="#string/dialog_etMin"
android:inputType="number"
android:layout_alignParentRight="true" />
<TextView
android:id="#+id/tvSegundo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/etMinimo"
android:text="#string/dialog_maxmin"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etMaximo2"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/tvSegundo"
android:ems="10"
android:hint="#string/dialog_etMax"
android:inputType="number"
android:layout_alignParentRight="true" />
<TextView
android:id="#+id/tvTexto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/etTexto"
android:layout_alignParentStart="true"
android:text="#string/diaog_textoTitulo"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etTexto"
android:layout_width="193dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="180dp"
android:ems="10"
android:hint="#string/diaog_etTextoTitulo"
android:inputType="textPersonName"
android:layout_alignParentRight="true" />
<LinearLayout
android:layout_width="360dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/btnCancelar"
android:layout_width="176dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="19dp"
android:layout_toLeftOf="#+id/etTexto"
android:layout_toStartOf="#+id/etTexto"
android:background="#drawable/boton_redondeado2"
android:text="#string/iniciar_sesion_cancelar"
android:textColor="#android:color/background_light" />
<Button
android:id="#+id/btnGuardar"
android:layout_width="178dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/btnCancelar"
android:layout_marginEnd="9dp"
android:layout_marginRight="9dp"
android:background="#drawable/boton_redondeado"
android:text="#string/diaog_guardar"
android:textColor="#android:color/background_light" />
</LinearLayout>
See here
Run time view look like this
Can someone help me because I'm desperate. My English is bad, so I accept edits
When using RelativeLayout, instead of using
android:layout_alignParentBottom="true"
android:layout_marginBottom="180dp"
like you are doing in the EditText with with id #+id/etTexto, you can simply write this code: android:layout_below="#id/etMaximo2"
You can even place some android:layout_marginTop if you want to add more space between the two Views.
P.S. For testing in the design view, know that you can change the dimensions of the device you're testing, so you can see in the "Preview" window what it would look like on device with different screen sizes. You can change this in the top toolbar of the preview window.
I hope this helps you! :)
Give this id to the LinearLayout:
android:id="#+id/layout"
and add this attribute to etTexto:
android:layout_above="#+id/layout"
also adjust the bottom margin as you like.
Try to delete android:layout_alignParentEnd="true" and then clean your project after the clean, run again.
Make sure that your Relative Layout is closed right after the linear ends
</LinearLayout>
</RelativeLayout>
Does it work now?
I used this xml and it worked on a Nexus 5 emulator
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvInicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:text="TEST"
android:textColor="#color/colorPrimary"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvPrimero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="85dp"
android:text="test"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etMaximo"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tvPrimero"
android:layout_alignParentEnd="true"
android:ems="10"
android:hint="test"
android:inputType="number"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/etMinimo"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="151dp"
android:ems="10"
android:hint="test"
android:inputType="number"
android:layout_alignParentRight="true" />
<TextView
android:id="#+id/tvSegundo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/etMinimo"
android:text="test"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etMaximo2"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/tvSegundo"
android:ems="10"
android:hint="test"
android:inputType="number"
android:layout_alignParentRight="true" />
<TextView
android:id="#+id/tvTexto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/etTexto"
android:layout_alignParentStart="true"
android:text="test"
android:textColor="#color/colorPrimary"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/etTexto"
android:layout_width="193dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="180dp"
android:ems="10"
android:hint="this should stay right here"
android:inputType="textPersonName"
android:layout_alignParentRight="true" />
<LinearLayout
android:layout_width="360dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/btnCancelar"
android:layout_width="176dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="19dp"
android:layout_toLeftOf="#+id/etTexto"
android:layout_toStartOf="#+id/etTexto"
android:background="#color/colorPrimary"
android:text="button"
android:textColor="#android:color/background_light" />
<Button
android:id="#+id/btnGuardar"
android:layout_width="178dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/btnCancelar"
android:layout_marginEnd="9dp"
android:layout_marginRight="9dp"
android:background="#color/colorAccent"
android:text="button"
android:textColor="#android:color/background_light" />
</LinearLayout>
</RelativeLayout>
Maybe you should try putting it below EditText that is above it?
Remove
android:layout_alignParentBottom="true"
android:layout_marginBottom="180dp"
Add
android:layout_below="#+id/etMaximo2"
Result
<EditText
android:id="#+id/etTexto"
android:layout_width="193dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/etMaximo2"
android:ems="10"
android:hint="#string/diaog_etTextoTitulo"
android:inputType="textPersonName"
android:layout_alignParentRight="true" />
Then set some top margin android:layout_marginTop="{some value}dp" to make it look like you want.

How to handle different font sizes of text?

This is my issue.
All text size in my app screen looks fine when my user chooses font size to be small from android
settings-->display -->Text size --> small
same app screen looks messy when my user chooses font size to be large from android
settings-->display -->Text size --> Large
How to make my app screens look better in all font sizes
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/voicemailcontactpic"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:src="#drawable/unknown_contact"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="#+id/voicemailcontactname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/transparent"
android:ellipsize="end"
android:text="Unknown"
android:maxLines="1"
android:textSize="14sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:layout_toEndOf="#id/voicemailcontactpic"
android:layout_toRightOf="#id/voicemailcontactpic"
android:layout_alignTop="#+id/voicemailcontactpic"/>
<TextView
android:id="#+id/voicemailcontactnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/voicemailcontactname"
android:layout_alignStart="#+id/voicemailcontactname"
android:layout_below="#+id/voicemailcontactname"
android:layout_alignBottom="#+id/voicemailcontactpic"
android:background="#color/transparent"
android:ellipsize="end"
android:maxLines="1"
android:text="1234"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:textSize="12sp" />
<TextView
android:id="#+id/voicemaildownloadsize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/voicemaildownload"
android:layout_toLeftOf="#id/voicemaildownload"
android:layout_alignTop="#id/voicemailcontactpic"
android:text="122kb"
android:textSize="12sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:textAlignment="viewEnd"
tools:ignore="RtlCompat"
/>
<TextView
android:id="#+id/voicemailrecievedtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/voicemaildownload"
android:layout_toLeftOf="#id/voicemaildownload"
android:layout_below="#+id/voicemailcontactname"
android:layout_alignBottom="#id/voicemailcontactpic"
android:text="12:01 PM"
android:textAlignment="viewEnd"
android:textSize="12sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
tools:ignore="RtlCompat"
/>
<com.nexge.nexgetalkclass5.app.voicemail.CircularProgressBar
android:id="#+id/voice_mail_file_download_Progress"
style="#style/Widget.ProgressBar.Holo.CircularProgressBar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="16dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="16dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
/>
<ImageView
android:id="#+id/voicemaildownload"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignBottom="#+id/voicemailcontactpic"
android:layout_alignTop="#id/voicemailcontactpic"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/voicemail_download"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/voicemail_player_layout"
android:paddingBottom="10dp"
>
<ImageView
android:id="#+id/voicemail_player_play_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:src="#drawable/media_player_play"
/>
<ImageView
android:id="#+id/voicemail_player_pause_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:src="#drawable/media_player_pause"
android:visibility="invisible"
/>
<SeekBar
android:id="#+id/voicemail_player_seekbar"
android:layout_width="match_parent"
android:layout_toEndOf="#+id/voicemail_player_play_btn"
android:layout_toRightOf="#+id/voicemail_player_play_btn"
android:layout_alignTop="#+id/voicemail_player_play_btn"
android:progressTint="#color/colorPrimary"
android:thumb="#drawable/seekbar_thumb"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"/>
<TextView
android:id="#+id/voicemail_file_start_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/voicemail_player_seekbar"
android:layout_alignStart="#+id/voicemail_player_seekbar"
android:layout_alignLeft="#+id/voicemail_player_seekbar"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:fontFamily="calibri"
/>
<TextView
android:id="#+id/voicemail_file_end_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="calibri"
android:layout_alignEnd="#+id/voicemail_player_seekbar"
android:layout_alignRight="#+id/voicemail_player_seekbar"
android:layout_below="#+id/voicemail_player_seekbar"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
/>
</RelativeLayout>
</LinearLayout>
Don't use textsize, Use textAppearance for fontSize

My android app has an issue with fragment border

Here is the screen shot from my app which has a border annoying me with not fitting on mobile screen:
Even if I try it with any layout (Relative linear or Frame).
This border pops up only when I use fragment in NAVIGATION DRAWER and this looks normally when viewed in Android studio design window but when you run on a mobile it adds the border to it has the attachment screenshot given above.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2579BF"
android:layout_margin="0dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="40dp"
android:inputType="textPersonName"
android:background="#drawable/roundedcircle"
android:drawableRight="#drawable/people"
android:hint="Name"
android:ems="10"
android:id="#+id/editText3"
android:layout_gravity="center_horizontal|top"
android:layout_marginBottom="30dp"
android:layout_marginTop="20dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="39dp"
android:background="#drawable/roundedcircle"
android:inputType="textEmailAddress"
android:drawableRight="#drawable/email"
android:layout_marginTop="70dp"
android:hint="E-Mail"
android:ems="10"
android:id="#+id/editText4"
android:layout_gravity="center_horizontal|top" />
<EditText
android:layout_width="wrap_content"
android:layout_height="46dp"
android:inputType="phone"
android:hint="Contact Details"
android:layout_marginBottom="30dp"
android:layout_marginTop="0dp"
android:ems="10"
android:drawableRight="#drawable/phone"
android:background="#drawable/roundedcircle"
android:id="#+id/editText6"
android:layout_gravity="center" />
<Button
android:layout_width="322dp"
android:layout_height="wrap_content"
android:text="UPDATE NEW ACCOUNT"
android:drawableLeft="#drawable/arrows"
android:background="#drawable/roundedcircle"
android:backgroundTint="#b9b4b4"
android:layout_marginTop="1dp"
android:layout_marginBottom="25dp"
android:id="#+id/button3"
android:layout_gravity="center_horizontal|bottom" />
<EditText
android:layout_width="250dp"
android:layout_height="124dp"
android:inputType="textMultiLine"
android:drawableRight="#drawable/address"
android:hint="Postal Address"
android:background="#drawable/roundedcircle"
android:layout_marginTop="115dp"
android:ems="10"
android:id="#+id/editText5"
android:layout_gravity="center_horizontal|top" />
<CheckBox
android:layout_width="133dp"
android:layout_height="wrap_content"
android:text="Message Notification"
android:background="#drawable/roundedcircle"
android:layout_marginTop="1dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="-20dp"
android:drawableRight="#drawable/smsnotification"
android:id="#+id/checkBox2"
android:layout_gravity="end|center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Picture scan"
android:layout_marginTop="33dp"
android:layout_marginBottom="-25dp"
android:textColor="#ffffff"
android:drawableRight="#drawable/sign"
android:id="#+id/textView7"
android:layout_gravity="center" />
<FrameLayout
android:layout_width="299dp"
android:layout_height="137dp"
android:background="#drawable/roundedcircle"
android:layout_marginBottom="25dp"
android:layout_marginTop="170dp"
android:id="#+id/profilepicture"
android:layout_gravity="center"></FrameLayout>
<CheckBox
android:layout_width="135dp"
android:layout_height="wrap_content"
android:text="E-mail Notification"
android:drawableRight="#drawable/emailnotification"
android:layout_marginTop="1dp"
android:layout_marginLeft="-80dp"
android:layout_marginBottom="-20dp"
android:background="#drawable/roundedcircle"
android:id="#+id/checkBox"
android:layout_gravity="center" />
</FrameLayout>
I'm sure op already solved this, but the solution is to remove all padding in content_main.xml. Just saying for other people who might run into the same issue.

RelativeLayout Problems with differences in height

In my android studio it should be like this
http://i.imgur.com/iCvntB9.png
but when I run it on my phone it shows up like this with the 2 edittexts that have moved up a bitin relation compared to the backround screen.
http://i.imgur.com/2Cmjz4B.png
I am relatively new to android and would like help on how to make sure that it will be in ratio and work on different phone sizes. It is the 2 editTexts that have changed position. Thanks in advance
XML CODE FOR REFERENCE
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#+id/imageView2"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="#drawable/mainscreen" />
<ImageView
android:layout_width="260dp"
android:layout_height="170dp"
android:id="#+id/imageView"
android:background="#drawable/title"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" />
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/button"
android:background="#drawable/predict_b"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Enter Name"
android:maxLength="20"
android:linksClickable="false"
android:layout_below="#+id/imageView"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button"
android:layout_marginTop="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Age"
android:maxLength="20"
android:linksClickable="false"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:layout_below="#+id/editText" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="43dp"
android:layout_below="#+id/editText2"
android:layout_toLeftOf="#+id/button"
android:layout_toStartOf="#+id/button" />
why not using LinearLayout instead ?
use LinearLayout with orientation vertical
or you can also use it with weightSum tag
Add this to your EditTExt:
android:textAlignment="center"
android:gravity="center"
Add the following attribute to the activity in your AndroidManifest.xml:
android:windowSoftInputMode="adjustResize"
Try modifying your layout as:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#drawable/urLogiOrTitle" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView2"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:linksClickable="false"
android:maxLength="20"
android:text="Enter Name" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:linksClickable="false"
android:maxLength="20"
android:text="Age" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="predict" />
</RelativeLayout>

Background Image Stretched when taping text filed inside scroll view

I created one registration page using relative layout and applied background image to main layout. Here I used scroll view for scrolling my contents.
Problem: when I selected my textfield, background image of main relative layout stretched.
Here is my xml content:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:androidcustomfont="http://schemas.android.com/apk/res/com.cpt.realtor.activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="615dp" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="680dp" >
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="25dp"
android:src="#drawable/realtor_land_text" />
<EditText
android:id="#+id/editFirstName"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/firstname"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editLastName"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editFirstName"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/lastname"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editCompany"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editLastName"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/company"
android:inputType="text" />
<EditText
android:id="#+id/editMobile"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editCompany"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/mobile"
android:imeOptions="actionDone"
android:inputType="phone"
android:maxLength="10" />
<EditText
android:id="#+id/editEmail"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editMobile"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/email"
android:inputType="textEmailAddress" />
<Spinner
android:id="#+id/spinnerForStates"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editEmail"
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp" />
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinnerForStates"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:button="#drawable/checkbox_selector"
android:text="#string/receivealert"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold" />
<com.cpt.realtor.utility.CustomFontButton
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox"
android:layout_marginLeft="180dp"
android:layout_marginTop="10dp"
android:background="#drawable/share_btn_selector"
android:text="#string/submit"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
androidcustomfont:customFontView="clarendon_regular.ttf" />
<TextView
android:id="#+id/textSkip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/submit"
android:layout_marginLeft="205dp"
android:layout_marginTop="8dp"
android:textSize="15sp"
android:text="#string/skip_this_step"
android:textColor="#color/white" />
<View
android:id="#+id/splitter"
android:layout_width="93dp"
android:layout_height="1dip"
android:layout_below="#+id/textSkip"
android:layout_marginLeft="210dp"
android:layout_marginTop="0dp"
android:background="#color/white" />
<View
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/textSkip"
android:background="#drawable/footer" />
</RelativeLayout>
</ScrollView>
without selecting TextField:
After selecting TextField:
In my second image, the background image stretched. How can I solve this?
In your manifest write this in activity tag
android:windowSoftInputMode="stateVisible|adjustPan"

Categories

Resources