Thursday, August 12, 2010

[android-developers] Re: hi, i'm newbie in android, i wonder about float dp...

thanks Earl, I understand of yours.
but I still wonder..

it's no matter as I coding button's width, 150dp, then make an element
as 100px image in photoshop.

but,
first i draw a button as a pixel 100 for visual design. then it's
necessary to convert to float data(it'll be 66.666666.....dp).
it occurs a problem.

So, When I'm designing, the application as a VD, Do I consider this
issue and make limit px work as 3px(it'll be 2dp)?


On 8월10일, 오전6시26분, Joseph Earl <joseph.w.e...@gmail.com> wrote:
> Your calculation is wrong, it should be
>
> buttonWidth = (currentDPI/160)*100;
>
> So if currentDPI = 240 then buttonWidth = 150px
>
> Instead of using (currentDPI/160) use
> final float scaleDPI =
> getContext().getResources().getDisplayMetrics().density;
>
> and then
>
> buttonWidth = scaleDPI*100;
>
> Seehttp://developer.android.com/guide/practices/screens_support.html#sup...
> for more information on the topic.
>
> On Aug 9, 12:05 pm, hwani <hwanii...@gmail.com> wrote:
>
>
>
> > hi, guys.
>
> > is it possible, coding float data to layout_height(int)?
>
> > some problems occur in layout design, px to dp convert.
>
> > ex) i designed some layout, in px work.(button width 100px)
> > then i build the layout to dp.(button width 66.67dp :
> > 66.666667dp(100px*160/240))
>
> > regards,

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate