0

I have a condition that says if it's a textview then use a relative layout to hold it, however, if it is a youtubeplayersupportfragment, then use a linear layout. The reasoning behind this is because the youtube player api "doesn't allow view overlays" -_-*. Anyway, I enjoy having the view overlay in any other case besides the youtubeplayersupportfragment, and I just want to use weighting in the case of the youtubeplayer, so that it will comply with the terms of service, and balance the views so that none are overlaying.

My real question is: is it possible to efficiently interchange parent layouts holding items without causing too much overhead? I understand that this is a very specific case, so there probably is no way to do this, and I will probably end up being forced to always use a linear layout to comply with TOS :(

Please help a new androiddev out!

Also, is there a way to force it so that there is no overlay in a relative layout?

edit:

Ok so, here's my layout so far. Don't mind the surfaceview, it's helping a youtube glitch...

I'd like to change the HackyViewPager, to delete the layout_above parameter when there is a youtube fragment loaded into the viewpager. Is there a way to delete a parameter like that? If there is not, then is there a way to say 'Layout_above="bottom of the screen"?'

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}"
    android:background="#000000"
    android:orientation="vertical">

    <asdfsdf.adfaf.asfdfa.HackyViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="false"
        android:layout_above="@id/popupMenuButton"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"/>


    <SurfaceView
        android:layout_width="0px"
        android:layout_height="0px"
        android:visibility="gone"
        android:id="@+id/surfaceView" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/popupMenuButton"
        android:layout_gravity="end"

        style="?android:attr/borderlessButtonStyle"
        android:src="@drawable/popupmenubutton"
        android:background="@null"
        android:onClick="showPopupMenu"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />




</RelativeLayout>
slackbot39243
  • 241
  • 3
  • 15
  • 2
    Generate the layouts on the fly: at run time when needed. – greenapps Jul 01 '14 at 08:37
  • 1
    Create the too versions of your layout in xml files, then inflate one or the other depending on your condition. – Guian Jul 01 '14 at 09:22
  • Yes! Greenapps to the rescue again! Ok, so I am now aware that inflating the new layout each time on the fly wouldn't be too too terrible, since that is essentially what a pageadapter is doing in the first place. However, I think I may be able to do it an easier way. I posted my code and my edit. TL;DR I want to 'delete/hide' the 'android:layout_above' parameter when it isn't a youtube video getting loaded, and when it is, activate that parameter. I'm not sure how to say, layout_above="null" or rather, switch back and forth. PS: I need 4 xml files if I did it the inflation way, 2 land, 2 port – slackbot39243 Jul 01 '14 at 11:58
  • What about removing the layout_above rule programmatically? http://stackoverflow.com/questions/5107740/how-do-i-programmatically-remove-an-existing-rule-that-was-defined-in-xml – Marina.Eariel Sep 18 '14 at 21:41

0 Answers0