문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top