Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
TheTurtleKing

[semi-solved] Android Studio - XML looks nothing like the layout when emulated?

Recommended Posts

Posted · Original PosterOP

So, uh, title explains it. 

 

Whenever I try to emulate my xml layout on a Pixel emulator, everything gets all bunched up.

what did I do wrong?

halp

 

 

android studio help.png

Link to post
Share on other sites
Posted · Original PosterOP
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="com.example.turtle.testmed.MainActivity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/sign_in"
        tools:layout_editor_absoluteX="172dp"
        tools:layout_editor_absoluteY="91dp" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress"
        tools:layout_editor_absoluteX="72dp"
        tools:layout_editor_absoluteY="132dp"
        android:width="240dp"/>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        tools:layout_editor_absoluteX="72dp"
        tools:layout_editor_absoluteY="234dp"
        android:width="240dp"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Continue"
        tools:layout_editor_absoluteX="146dp"
        tools:layout_editor_absoluteY="355dp" />

</android.support.constraint.ConstraintLayout>
Link to post
Share on other sites
Posted · Original PosterOP
42 minutes ago, TheTurtleKing said:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="com.example.turtle.testmed.MainActivity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/sign_in"
        tools:layout_editor_absoluteX="172dp"
        tools:layout_editor_absoluteY="91dp" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress"
        tools:layout_editor_absoluteX="72dp"
        tools:layout_editor_absoluteY="132dp"
        android:width="240dp"/>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        tools:layout_editor_absoluteX="72dp"
        tools:layout_editor_absoluteY="234dp"
        android:width="240dp"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Continue"
        tools:layout_editor_absoluteX="146dp"
        tools:layout_editor_absoluteY="355dp" />

</android.support.constraint.ConstraintLayout>

update: added

android:gravity="center"
android:layout_gravity="center"

to lines 8 and 9.

 

still no luck so I deleted those lines.

Link to post
Share on other sites

The XML Source you posted had just the constraints for the correct rendering in the design view in Studio. It was missing the correct layout attributes like app:layout_constraint.... The constraint attributes prefixed with tools: just contain absolute positions for the layout editor. 

For your theme issue, try to change the theme inside your AndroidManifest.xml  and rebuild your project. This should solve your issue 


"I speak English very well, bröcklersweiß und nier zu schnell"

-- Probably the favorite quote from bavarian students

Codepen http://codepen.io/MoVo99/

Software Skills

  • HTML, CSS & Client Side JavaScript
  • PHP (Laravel & Lumen)
  • JavaScript (NodeJs with Express)
  • Java (Android SDK; Bukkit SDK)
  • Ruby On Rails (Just learning.... 20%)
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×