Is there a way to set layout height to wrap content on the adapter?
The layout that I inflate in my adapter has two parts. One of the parts is visible while the other one is gone, but both of them has wrap_content for the height. Like:
<LinearLayout ... android:visibility="gone" > <View ... android:visibility="visible" /> <View ... android:visibility="gone" /> <LinearLayout>
Now, with a press of a button, the second view’s visibility will be set to visible. But problem is that it doesn’t wrap it’s content. The height it only uses is the height from the first view, the one who’s already visible.
I tried to set:
view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
next after I set the view’s visibility to visible, but it did not work.
So, is there a way? Or can you suggest any workaround? Thank you so much.