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; See http://developer.android.com/guide/practices/screens_support.html#support for more information on the topic. On Aug 9, 12:05 pm, hwani <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

