(Android版)布局不会setVisibility(view.GONE)后重绘? [英] (Android) Layout won't redraw after setVisibility(view.GONE)?
问题描述
在应用程序我有:
的LinearLayout linearLayout2 =(的LinearLayout)findViewById(R.id.cvLinearLayout2);
In app I have: LinearLayout linearLayout2 = (LinearLayout) findViewById(R.id.cvLinearLayout2);
和之后:
linearLayout2.setVisibility(View.GONE);
我不能找到一个办法让linearLayout2回??
Tryed一切:
linearLayout2.setVisibility(View.VISIBLE);
linearLayout2.bringToFront();
linearLayout2.getParent().requestLayout();
linearLayout2.forceLayout();
linearLayout2.requestLayout();
linearLayout2.invalidate();
但没有结果。
linearLayout2有一个parrent linearLayout1,所以我也tryed:
but with no results. linearLayout2 have one parrent linearLayout1, so I tryed also:
linearLayout1.requestLayout();
linearLayout1.invalidate();
仍然为零的结果,linearLayout2 stayes GONE?
我需要在我的应用程序移动的LinearLayout走,然后,过了一段时间再重新绘制。请帮助。
still with zero results, linearLayout2 stayes GONE ?? I need in my app to move linearLayout away, and then, after a while to redraw it again . Please help.
推荐答案
视图的可见性设置为GONE应该不会影响它的通过使用方法setVisibility(View.VISIBLE)回来的能力。
Setting a View's visibility to GONE should not affect it's ability to "come back" by using the method setVisibility(View.VISIBLE)
例如我有这样的code在我的应用程序之一:
For example I have this code in one of my apps:
public void onCheckedChanged(CompoundButton checkBox, boolean isChecked{
if(checkBox == usesLocationCheckBox)
{
View view = findViewById(R.id.eventLocationOptions);
if(isChecked)
{
view.setVisibility(View.VISIBLE);
usesTimeCheckBox.setEnabled(false);
}
if(!isChecked)
{
view.setVisibility(View.GONE);
usesTimeCheckBox.setEnabled(true);
}
}}
和它完美的罚款。其他一些code你的程序执行必须负责。编辑您的帖子相关code和我们或许可以给你一个更好的答案。
And it works perfectly fine. Some other code your program is executing must be responsible. Edit your post with the relevant code, and we may be able to give you a better answer.
这篇关于(Android版)布局不会setVisibility(view.GONE)后重绘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!