A
A
afch2014-05-30 20:17:45
Android
afch, 2014-05-30 20:17:45

Why does markup look different in Android Studio and on real devices or emulators?

The markup looks different in Android Studio and on real devices or emulators, why is that? How to fix?
This is how the markup was supposed to look like, and this is how it looks in the Android Studio editor, the entire markup code is visible on the same screenshot:
b83ac5545f4e4ca68b58dd9bf5e3fa8a.png

<?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:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/top"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/top"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/start"
        android:layout_below="@+id/top"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="-16dp"
        android:src="@drawable/start"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cleft"
        android:layout_below="@+id/top"
        android:src="@drawable/cleft"
        android:layout_alignLeft="@+id/top"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cright"
        android:layout_below="@+id/top"
        android:src="@drawable/cright"
        android:layout_alignRight="@+id/top"
        />
</RelativeLayout>

And this is how it looks on my phone:
ad642f1e451841b3a2d1d0aff39ed817.png
and in the mode of displaying the borders of elements:
8bd0f61af3bb49b193022c44f0f4fac9.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Yakushev, 2014-05-31
@VYakushev

It's possible that Android Studio doesn't know how to work with negative indents.

A
afch, 2014-05-31
@afch

Yes, by the way, in Eclipse it is really displayed correctly both at the development stage and at runtime, it’s not clear only what does the development environment have to do with it, because this XML, as it seems to me, is already drawn on the device “as is”?
I brought all the markup that is, and the full text is visible on the very first screenshot.
The problem was solved by returning to Eclipse'u. There it is displayed equally correctly both in the editor and on the device.

M
Mintormo, 2014-05-31
@Mintormo

The information you have given is not enough. The markup looks okay, but looking at the screenshot, I can't help feeling that it's inserted into another layout with padding.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question