简体   繁体   English

将Android RelativeLayout与消失的视图相结合

[英]Combining Android RelativeLayout with Gone Views

Is there a good way to combine RelativeLayout with Views that might be gone? 有没有将RelativeLayout与可能消失的View结合的好方法?

For example if I wanna have a row with four buttons, and the two in the middle might become visibility="gone" during some runtime cases. 例如,如果我要一行包含四个按钮,并且在某些运行时情况下,中间的两个按钮可能会变成“ visible =“ gone”。

I can't use android:layout_below because then they will not be neatly arranged instead they will overlap each other. 我不能使用android:layout_below,因为那样它们就不会整齐地排列,而是会彼此重叠。 I guess I could programmatically change which view is below which one, but that seems very messy. 我想我可以以编程方式更改哪个视图低于哪个视图,但这似乎很混乱。

Right now I usually end up adding a LinearLayout, but I wonder if there is any good way to achieve this without adding an extra layout. 现在,我通常通常会添加一个LinearLayout,但是我想知道是否有什么好方法可以在不添加额外布局的情况下实现这一目标。

You can use this flag 您可以使用此标志

android:layout_alignWithParentIfMissing="true"

take a look at the docs here 看看这里的文档

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

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