0

I have been developing an Android app using Android Studio and BlueStacks for the last while and everything turned out great. However, when I try to run the app on my physical device, all of the content displays very differently.

Everything looks great on the Bluestacks emulation (with the phone set in portrait mode) but then on the physical phone everything looks squashed together (as if the phone has a TINY resolution or something).

Has anyone seen anything similar? Is it just an issue with my physical device?

Here is an image of what the login page looks like in Emulator

And here's the physical device Screenshot

Here's my XML:

<?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/activity_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#ff292929"
tools:context="com.socialivemusic.socialivemusic.LoginActivity">
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    app:srcCompat="@drawable/socialogo"
    android:id="@+id/imageView"
    android:layout_gravity="center"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="50dp"
    android:layout_centerHorizontal="true"/>

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:layout_below="@+id/imageView"
    android:layout_marginBottom="50dp"
    android:ems="10"
    android:id="@+id/loginEmail"
    android:background="#ffffffff"
    android:hint="Enter Email"
    android:textColorHint="#ff434343"
    android:textColor="#ff292929"
    android:textSize="30sp"/>

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:layout_below="@id/loginEmail"
    android:ems="10"
    android:id="@+id/loginPw"
    android:background="#ffffffff"
    android:hint="Enter Password"
    android:textColorHint="#ff434343"
    android:textColor="#ff292929"
    android:layout_marginBottom="@dimen/activity_horizontal_margin"
    android:textSize="30sp"/>

<Button
    android:text="LOGIN"
    android:textColor="#ffffffff"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_marginTop="@dimen/activity_horizontal_margin"
    android:id="@+id/loginButton"
    android:background="#08AE9E"
    android:layout_below="@+id/loginPw"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:textSize="30sp"/>

<TextView
    android:text="I fogot my Password"
    android:textColor="#ffffffff"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/loginButton"
    android:layout_marginTop="@dimen/activity_horizontal_margin"
    android:layout_centerHorizontal="true"
    android:id="@+id/toPwRedo"
    android:textSize="20sp"/>

<Button
    android:text="REGISTER"
    android:textColor="#ffffff"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentBottom="true"
    android:id="@+id/toRegister"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="#ff434343"
    android:textSize="30sp"/>
</RelativeLayout>
aodhaganor
  • 15
  • 7
  • it's not an issue. Your bluestack preview is more like that of a large screen phones, while your physical device is smaller in size. To rectify this design your layouts according to different screen sizes. – Vivek Mishra Mar 28 '17 at 09:20

1 Answers1

0

It's because your device's & emulator's sizes are different. When you are giving sizes in dp you should put these sizes in files of dimens.xml, dimens.xml (w600dp), dimens.xml (w720dp), dimens.xml (w820dp) & many more, to cater for devices of different densities & resolutions.

Eg: dimens.xml- <dimen name="d2dp">2dp</dimen>, dimens.xml (w600dp)- <dimen name="d2dp">3dp</dimen>, dimens.xml (w720dp)- <dimen name="d2dp">4dp</dimen>

Then use it in your layout as android:layout_height="@dimen/d2dp"

Read about handling screens of different sizes.

Aishwarya Tiwari
  • 625
  • 4
  • 19
  • Ah okay, thanks very much for the information! I'll spend the day sorting out the various dimensions! – aodhaganor Mar 28 '17 at 09:37
  • Sure thing, could you point me in the direction of some good tutorials of how to go about this? Just want to make sure I do everything correctly! – aodhaganor Mar 28 '17 at 10:11
  • Sorry, I've no useful links currently, but I did some research for you and I feel you should read about smallest width concept. [This](https://developer.android.com/training/multiscreen/screensizes.html) & [This](https://android-developers.googleblog.com/2011/07/new-tools-for-managing-screen-sizes.html) will give you a brief idea about it. Rest you will have to research. – Aishwarya Tiwari Mar 28 '17 at 11:03
  • [This](http://stackoverflow.com/questions/36820746/how-to-design-any-screen-size-and-density-in-androidmulti-screen-for-mobiles/36821546#36821546) is an answer on stackoverflow explaining how to use dimens. – Aishwarya Tiwari Mar 28 '17 at 11:09