4

Within my application I have an error in the graphical layout which shows up as:

error!
UnsupportedOperationException: Can't convert to dimension: 15
Exception details are logged in Window > Show View > Error LogThe following classes could not be found:
- TextView

When I run the application this works, but it shows the error in the graphical layout, does anyone know the cause of this.

It occurs when I put android:layout_marginTop="-3dip" , if I dont use - then this doesn't show.

Thanks

2 Answers 2

3

I doubt you still need help with this problem; however, I ran into a similar message and thought I would share to hopefully help anyone else that might run into this error message.

I found that the error was only occurring in the "2.7in QVGA slider" device configuration. I also found that if I changed the negative value to a different number I no longer got the error message.

So, I ended up using -2 instead.

I am going to guess the error is caused by some of the scaling calculations in the graphical renderer. But it's not worth researching to find out at this point.

Sign up to request clarification or add additional context in comments.

Comments

3

There is no such thing as a negative margin. Use android:gravity="top" if your textview is higher than your textsize and you want the text to appear on the top. Otherwise use android:layout_height="wrap_content". Your view will exactly fit this way.

If you want 3dp space between the top border of the textview and the actual text, use android:paddingTop="3dp". Generally, margin is the free space outside the view, padding is the inside spacing between the border and the content.

Actually negative margins can be used in LinearLayout.
@Romain can it not be used in RelativeLayout?
You can use negative margins in RelativeLayout too.
In a RelativeLayout, "-1dp" in attribute "layout_marginTop" is not a valid format. That's what the designer says.
@RomainGuy is this expected behaviour and only fixable with negative margins? stackoverflow.com/q/17525084/1322226

Your Answer

Draft saved
Draft discarded

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.