Pergunta

I have been working on android for the last 6 months. I wonder why UI Design is done in "dp"s. It would be great if its mentioned in "%" instead of dp's. What i meant to say is assuming total width and height of the screen to "100%" we can divide the width and height of the each widget. may be like this:

<ImageView android:layout_width="20%" android:layout_height="20%" />

So that every screen automatically takes it. Offcourse "wrap_content" and "fill_parent" can do. But cant use them to all views. I dont know if its possible or not.

Foi útil?

Solução

It's just the UI design aspect of Google that it's not possible to do what you intend to. That's 'cuz the layout height and width take integer values. However, layout weight takes decimal values in the form of percentage. So, in a way it's possible to do what you're trying to, but only with weight and not with height or width. +1 for the question.

Outras dicas

i think you cant use "%" in layout xml, you can use layout weight

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top