开发者

Android: custom views with proportional widths and same heights

I try to implement a good reusable color picker for my Sketcher application. Instructions and screenshots are here: http://bit.ly/sketcherapp

The problem is I'm stuck with a good "resizable" UI which enable me to support wide range of devices with different screen sizes.

Android: custom views with proportional widths and same heights

The top two widgets should be the same height and have proportional widths: 80 to 20. Also it would be nice to specif开发者_如何学Pythony paddings in XML.

Current implementation is not good. I hardcoded some values into code and also it looks bad on Xoom devices because of inaccurate layout measurements.

Is there any way to implement this behavior? Ideally, I need some way to do it like with HTML tables (pseudocode):

table.width=100%, td1.width=80%, td2.padding=5px, ...

or something like that.

Current implementation:

  • code: https://github.com/wargoth/Sketcher/tree/master/src/org/sketcher/colorpicker
  • layout: https://github.com/wargoth/Sketcher/blob/master/res/layout/color_picker.xml

Thank you.


The top two widgets should be the same height and have proportional widths: 80 to 20.

Use a horizontal LinearLayout, android:layout_width="0dip" for both widgets, and android:layout_weight="80" and android:layout_weight="20", respectively.

Also it would be nice to specify paddings in XML.

Use android:paddingLeft and kin.


OK. I stopped boring with it and created dedicated layouts for each screen size.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜