-4

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

enter image description here

Omkar
  • 3,040
  • 1
  • 22
  • 42
Shoaib
  • 3
  • 5

2 Answers2

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