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 开发者_JAVA百科on the screen. How is that possible?
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
精彩评论