简体   繁体   English

android UI中的相对位置

[英]relative positions in android UI

i have a problem in designing user interface and layouts. 我在设计用户界面和布局时遇到问题。 i want that some views relates to others. 我希望某些观点与其他观点相关。 for example a button related to a TextView and when i sat margin top, it calculates from that TextView not screen top. 例如,一个与TextView相关的按钮,当我坐在顶部时,它将根据该TextView而不是屏幕顶部进行计算。 how i can do this? 我该怎么做?

使用RelativeLayout ,视图将相对于其他视图定位。

From what you have written it seems like you could group the TextView and Button into a container view, like a RelativeLayout, and fit them inside there with the appearance you would like. 从您编写的内容来看,似乎可以将TextView和Button分组到一个容器视图中,例如RelativeLayout,然后将其与所需的外观一起放入其中。 Then you can set the margin of the Relative layout. 然后,您可以设置相对布局的边距。

Edit: Clarity 编辑:清晰度

Have a look at Relative Layouts . 看一下相对布局 They are the answer to your question. 它们是您问题的答案。 You can relate a view to another by setting it toLeftOf , below , alignParentTop or any other combination. 可以通过设置它涉及一个视图向另一个toLeftOfbelowalignParentTop或任何其他组合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM