Why my view is till showing shade after removing from layout. i have tried view.postInvalidate();
and other method
what is solution for that
here is the image
Asked
Active
Viewed 1,313 times
-4
-
Use view.setVisibility(View.GONE); – Ranjan Jan 17 '18 at 06:50
-
you didn't show how you remove it from layout. I think you do it incorrectly – Vladyslav Matviienko Jan 17 '18 at 07:08
2 Answers
1
I am not sure how have you written your code.
You can try this:
((ViewManager)view.getParent()).removeView(view);
or this is how it is done normally:
Android remove view from parent
View myView = findViewById(R.id.hiddenLayout);
ViewGroup parent = (ViewGroup) myView.getParent();
parent.removeView(myView);
Android remove all child views
LinearLayout formLayout = (LinearLayout)findViewById(R.id.formLayout);
formLayout.removeAllViews();
You can refer the following answer:
Add & delete view from Layout

Mohit Ajwani
- 1,328
- 12
- 24
-
i have removed the views, now after removing it is showing the shad, like in image i have posted here, layout is not refreshing – Shoaib Jan 17 '18 at 07:14
-
that is correct but what code have you used to remove it? Also, why not hide the view instead of removal as it might need the system to redraw the screen elements? – Mohit Ajwani Jan 19 '18 at 17:13
0
In Layout, you can use: android:visibility="gone"
<TextView
android:id="@+id/layout_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:visibility="gone" />
In Activity(java) :
LinearLayout llone= (LinearLayout) view.findViewById(R.id.llone);// change id here
layone.setVisibility(View.GONE);

Gautam Chibde
- 1,167
- 3
- 14
- 27

Abhishek kumar
- 4,347
- 8
- 29
- 44