include Tag Not Always Displayed

Nathan Sokalski 4,111 Reputation points
2021-11-10T06:08:18.187+00:00

I have several xml layouts which I include using the include tag. All of these include tags have the same layout_column & layout_row, because only one of them is displayed at a time. However, some of them do not seem to be working (in the designer or runtime). But it is very confusing because sometimes if I remove the android:visibility="gone" from several of them, they are displayed, but then adding the android:visibility="gone" back in to only one of them hides them all. The root elements for the xml layouts referenced by the includes are GridLayout or LinearLayout (I don't know if this matters or not). Why is the visibility of my includes acting so erratically? Thanks.

Developer technologies | .NET | Xamarin
{count} votes

Answer accepted by question author
  1. Nathan Sokalski 4,111 Reputation points
    2021-11-11T16:13:30.957+00:00

    I think I may have found the problem. Even though the include tags had android:layout_rowWeight="1", they seem to only work when I use a height of wrap_content instead of 0dp (I thought that height was supposed to be 0dp when weight was being used). So when I changed my code from

    <include android:id="@+id/incEditPlayerNames" android:layout_width="match_parent" android:layout_height="0dp" android:layout_column="0" android:layout_row="1" android:layout_rowWeight="1" layout="@layout/editplayernamesscreenlayout"/>
    

    to

    <include android:id="@+id/incEditPlayerNames" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="0" android:layout_row="1" android:layout_rowWeight="1" layout="@layout/editplayernamesscreenlayout"/>
    

    it seemed to work. Does the include tag treat weights differently? But it seems to be working now, so I will consider the problem fixed unless I am told otherwise.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.