简体   繁体   English

当在可视化视图上方设置另一个视图时,如果在相对布局上设置可视性时,行为是否一致?

[英]is there a consistent behavior when we set visibility gone on relative layout when another view is set above the gone view?

I have a relative layout with two views: 我有两个视图的相对布局:

<RelativeLayout ...>

<view
android:id:""+@id/view1"
android:layout_above:"+@id/view2" />


<view
android:id:""+@id/view2"
android:layout_alignParentBottom="true" />

</RelativeLayout>

Is there consistent behavior when I set view2 Visibility to gone? 将view2的可见性设置为“消失”时,行为是否一致?

If I undestand you correctly you can do this in 3 ways: 如果我对您的理解不正确,可以通过以下三种方式进行:

  • in this case you should use linearlayout because it will always be above view2 even if its GONE ; 在这种情况下,您应该使用linearlayout因为它总是在view2之上,即使它已经消失了 ;
  • if you want to maintain view1 on top of view2 like putting view2 visibility to invisible ; 如果您想将view1维持在view2之上,例如将view2的可见性设置为invisible
  • or align view1 to parent if view2 is gone with this in your xml set to true: android:layout_alignWithParentIfMissing 或如果将xml中的view2设置为true,则将view1与父级对齐:android:layout_alignWithParentIfMissing

Let me know if I can help you. 让我知道我是否可以帮助您。

Edit: 编辑:
when you put the view to GONE is like it doesn't exist so, view1 will be placed just like this line doesn't exists: android:layout_above:"+@id/view2" 当您将视图放置到GONE上时,就像它不存在一样,将放置view1就像该行不存在一样:android:layout_above:“ + @ id / view2”

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

相关问题 当 View 设置为 GONE 时不调用 Android onScrolled - Android onScrolled not called when View is set to GONE 文本视图集可见性消失了 - Text View set visibility gone not working 设置视图可见性保留其他视图 - Set View Visibility GONE keep other views 当我为这个按钮设置可见性 GONE 时有一个混蛋 - There is a jerk when I set visibility GONE for this button 当单击该视图以外的任何其他内容时,如何将视图设置为“不可见”或“消失” - How to set a view to “invisible” or “gone” when anything other then that view is clicked on 如何设置滚动视图内并包含两个 TextView 的线性布局的可见性消失? - How to set visibility GONE of a Linear Layout which is inside a scroll view and contains two TextViews inside? 使用View.GONE时RelativeLayout可见性不起作用 - RelativeLayout Visibility is not working when using View.GONE 当可见性设置为 GONE 时如何删除空白空间 - How to remove empty space when visibility is set to GONE set.Visibility(View.GONE) 没有使 Button 和 EditText 消失,它的出现就像我什至没有添加代码一样 - set.Visibility(View.GONE) not making the Button and EditText gone, and it's showing up like I didn't even add the code 移除视图可见性消失后的调整大小动画 - Remove the resize animation on view visibility GONE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM