开发者

Draw Custom View on specific position of screen - Android

开发者 https://www.devze.com 2022-12-25 21:45 出处:网络
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 c

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

0

精彩评论

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

关注公众号