views:

287

answers:

1

I have a custom component which consists of 2 text view and 4 toggle buttons. I want to draw this view at some specific position on the screen. How is that possible?

+1  A: 

You could wrap the controls in a Layout, e.g. a LinearLayout, and add android:paddingLeft and android:paddingTop by some pixel value to that Layout to position it how you want.

However I would advise that Android Layouts are better designed with relative positions rather than absolute positions. Different devices have different screen sizes, and unless you prohibit it your layouts can be switched between Portrait to Landscape ratios without warning. Layouts designed with relative positioning hold up much better under these conditions. The RelativeLayout container allows tricks like centering controls on the screen, and aligning them relative to other controls.

http://developer.android.com/intl/de/reference/android/widget/RelativeLayout.html

Jim Blackler
How can i position a view to some specific position at runtime?
Pria