Note that there are some explanatory texts on larger screens.

plurals
  1. POFragments added to linearLayout are stacking, Causing only final one added is visible
    primarykey
    data
    text
    <p>I have a view that contains a YouTubePlayerSupportFragment, with a small box around it for styling. I want to add multiple instances of this view on top of each other (vertically) to another view. I have it working for adding a single view, but when I try to add multiple they just stack on each other, so that only the one that was added last is visible. I was able to prove this was happening, by programatically making the first view added longer and I could see the extra height of it beneath the topmost view.</p> <p>Here is my code:</p> <p><strong>fragment_youtube_video:</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:padding="5dp" android:layout_marginTop="5dp" android:background="#FFFFFFFF"&gt; &lt;fragment android:id="@+id/youTubeVideo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment" /&gt; &lt;TextView android:id="@+id/videoTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="4dp" android:layout_marginBottom="8dp" android:textColor="#000000" android:text="Video" /&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>fragment_videos:</strong></p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background"&gt; &lt;ImageView android:id="@+id/topBar" android:background="#000000" android:layout_width="match_parent" android:layout_height="45dp" /&gt; &lt;ImageView android:id="@+id/logoImageView" android:layout_width="120dp" android:layout_height="60dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:contentDescription="@string/CD_logo" android:src="@drawable/logo" /&gt; &lt;RelativeLayout android:id="@+id/pagerTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/logoImageView" android:background="#80000000" android:paddingBottom="10dp" android:paddingLeft="2dp" android:paddingRight="2dp" android:paddingTop="10dp" android:layout_marginLeft="12dp" android:layout_marginTop="5dp" android:layout_marginRight="12dp" &gt; [REMOVED FOR SPACE] &lt;/RelativeLayout&gt; &lt;ScrollView android:id="@+id/scrollableVideoBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@+id/pagerTitle" android:layout_alignRight="@+id/pagerTitle" android:layout_below="@+id/pagerTitle"&gt; &lt;LinearLayout android:id="@+id/videosLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#a0000000"&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>VideosFragment.java:</strong></p> <pre><code>private void addVideoViews() { int count = 0; FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); for (String vidURL : videoURLs) { new YoutubeFragment(); YoutubeFragment player = YoutubeFragment.newInstance(count, vidURL); fragmentTransaction.add(R.id.videosLayout, player, "x_" + count); count++; } fragmentTransaction.commit(); } </code></pre> <p>I could provide more code, but I believe these are the necessary pieces. Please also feel free to let me know if I am going about this incorrectly. I am so close, I just can't figure out for the life of me why they are stacking.</p> <p>Any help would be appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload