문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top