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.
Related
So, I was trying to create a customized wedding card in Android Studio. The code is given below. I noticed difference in textColor while building it in the emulator and real device. Though the color of this attribute has been defined as black but in the real device it appears as white. Screenshots of the real device and emulator appearance have been mentioned in the link below:
Appearance in the Real Device
Appearance in the Emulator
Android Studio Version: 4.1.1
Any suggestions about how this issue can be solved in terms of real device?
Thanks in advance.
<?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:id="#+id/wedding_Card"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/wedding_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="#drawable/wedding_card"
android:contentDescription="TODO" />
<ImageView
android:id="#+id/petals"
android:layout_width="325dp"
android:layout_height="716dp"
android:layout_centerInParent="true"
android:contentDescription="TODO"
app:srcCompat="#drawable/pink" />
<ImageView
android:id="#+id/flower_top"
android:layout_width="186dp"
android:layout_height="88dp"
android:layout_above="#id/save_date"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-30dp"
app:srcCompat="#drawable/floral_pattern"
android:contentDescription="TODO" />
<TextView
android:id="#+id/save_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/date"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/save_the_day"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold"
android:visibility="visible"
tools:visibility="visible" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/flower_bou"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/_25_12_2020"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
tools:visibility="visible" />
<TextView
android:layout_width="52dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginRight="6dp"
android:layout_marginBottom="7dp"
android:layout_toLeftOf="#id/flower_bou"
android:fontFamily="cursive"
android:text="#string/emma"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginEnd="6dp"
android:layout_toStartOf="#id/flower_bou" />
<ImageView
android:id="#+id/flower_bou"
android:layout_width="81dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
app:srcCompat="#drawable/flower_bouquet"
android:contentDescription="TODO" />
<TextView
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginStart="6dp"
android:layout_marginLeft="-21dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:layout_marginBottom="3dp"
android:layout_toRightOf="#id/bride_groom"
android:fontFamily="cursive"
android:text="#string/dexter"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_toEndOf="#id/bride_groom" />
<ImageView
android:id="#+id/bride_groom"
android:layout_width="133dp"
android:layout_height="111dp"
android:layout_centerInParent="true"
app:srcCompat="#drawable/bride_groom"
android:contentDescription="TODO" />
<TextView
android:id="#+id/We_getting_married"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/bride_groom"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/we_are_getting_married"
android:textColor="#color/black"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/time"
android:layout_centerHorizontal="true"
android:layout_below="#id/We_getting_married"
android:text="#string/at_five_o_clock_in_the_evening"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cityLove"
android:layout_centerHorizontal="true"
android:layout_below="#id/time"
android:text="#string/city_of_love"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/avenue"
android:layout_centerHorizontal="true"
android:layout_below="#id/cityLove"
android:text="#string/flower_avenue"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/church"
android:layout_centerHorizontal="true"
android:layout_below="#id/avenue"
android:text="#string/st_rose_church"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:id="#+id/dinner_dancing_to_follow"
android:layout_width="wrap_content"
android:layout_height="41dp"
android:layout_below="#id/church"
android:layout_centerHorizontal="true"
android:layout_marginTop="-10dp"
android:fontFamily="cursive"
android:text="#string/dinner_and_dancing_to_follow"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>
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.
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
I am creating gui in relative layout and reason i am using relative layout is that, i am using a fakeview in the middle of the screen to align all the other objects properly in the center of the screen. But the output on my mobile is completely different and is completely stretch out.
My problem is that the black line in the middle is supposed to be just 1dp in height, still it appears as 50dp in height on my device. Also there is huge gap in the middle below exchange rate and above discount amt($). Such problems weren't there in the emulator. the entire screen is divided into two parts, the lower part and upper part and there is gap in middle.
I am using nexus 4 running stock rom 4.4.2 to test my application.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#FFFFE0">
<View android:id="#+id/fakeView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/carat"
android:layout_marginTop="10dp"
android:layout_below="#+id/cut3"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/fakeView"
android:layout_marginRight="20dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/price"
android:layout_above="#+id/caratrs"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/fakeView"
android:layout_marginRight="20dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/list"
android:layout_marginRight="20dp"
android:layout_below="#+id/carat"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/fakeView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/total"
android:layout_marginRight="20dp"
android:layout_above="#+id/calculate"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/fakeView" />
<Spinner
android:drawSelectorOnTop="true"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="#+id/shape2"
android:layout_toLeftOf="#+id/color"
android:layout_alignLeft="#+id/cut3" />
<Spinner
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="#+id/cut3"
android:layout_below="#+id/shape2"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/fakeView"
android:layout_marginLeft="20dp"
/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/color"
android:layout_above="#+id/cut3"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/fakeView"
android:layout_marginRight="20dp" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/clarity"
android:layout_below="#+id/shape2"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/shape2"
android:layout_marginRight="20dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/discount"
android:layout_marginRight="20dp"
android:layout_below="#+id/list"
android:layout_toRightOf="#+id/fakeView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/converter"
android:layout_marginRight="20dp"
android:layout_below="#+id/discount"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/fakeView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculate"
android:id="#+id/calculate"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/black"
android:layout_below="#+id/converter"
android:layout_marginTop="20dp"
android:layout_alignParentLeft="true"
android:id="#+id/view"
android:layout_above="#+id/textView5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/discamt"
android:layout_below="#+id/view"
android:layout_above="#+id/price"
android:layout_alignLeft="#+id/fakeView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:layout_marginRight="20dp"
android:id="#+id/caratrs"
android:layout_above="#+id/total"
android:layout_toRightOf="#+id/fakeView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rap Price"
android:id="#+id/textView2"
android:layout_above="#+id/discount"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discount(%)"
android:id="#+id/textView3"
android:layout_above="#+id/converter"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exchange Rate"
android:id="#+id/textView4"
android:layout_alignBottom="#+id/converter"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discount Amt($)"
android:id="#+id/textView5"
android:layout_above="#+id/price"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PPC($)"
android:id="#+id/textView6"
android:layout_above="#+id/caratrs"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ppcrs"
android:id="#+id/textView7"
android:layout_above="#+id/total"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/Rs"
android:id="#+id/textView8"
android:layout_above="#+id/calculate"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Carat :"
android:id="#+id/textView9"
android:layout_alignBottom="#+id/carat"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"/>
</RelativeLayout>
In your black view remove
android:layout_above="#+id/textView5"
You'll end up with the following:
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/black"
android:layout_below="#+id/converter"
android:layout_marginTop="20dp"
android:layout_alignParentLeft="true"
android:id="#+id/view" />
You're already anchoring the view to converter
So you don't need the extra anchor.
I strongly recommend you not to use the fake view, from the screenshot, it is better to use linearlayout to hold blanks in the screen, and each blank you can use a relativelayout, in this way, this layout will look well in all devices
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"