1

I have the Layouts as you can see in the picture (sorry I cannot post them normally yet): https://dl.dropboxusercontent.com/u/28640502/Unbenannt.bmp

However, when I execute the app I can only see the camera preview and not the text nor the SeekBar. I know they work, because when I reduce the size of the camera I can see them and interact, but if I want the camera to be like background and then the children over it, it doesn't work.

I have been checking a lot of threads with similar problems but I don't find the solution: 1, 2, 3... Any idea? Thanks a lot!

Here is my xml code just in case:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.55"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/camera_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/show_height"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5sp"
                android:layout_marginRight="10sp"
                android:layout_weight="0.12"
                android:text="H" />

            <SeekBar
                android:id="@+id/select_height"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_margin="5sp"
                android:layout_weight="0.91" />

            <TextView
                android:id="@+id/show_distance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.06"
                android:text="Dist" />
        </LinearLayout>

    </FrameLayout>

</LinearLayout>
Community
  • 1
  • 1
serfe
  • 285
  • 5
  • 13

2 Answers2

2

try to input both of your layouts in relative layout for example

<LL>
  <RL>
    <FL>
    </FL>
    <LL>
    </LL>
  </RL>
</LL>

this is hapenning because of overlaiyng of LL by FL

Lebedevsd
  • 950
  • 5
  • 12
  • I mean, why in a RL the overlap doesn't occur and when I have tried with LL or making children of the FL it fails? – serfe Sep 18 '13 at 07:54
  • because you use camera content in FL, but if you will not init you RL with any class youll see all inner layouts – Lebedevsd Sep 18 '13 at 08:08
  • Oh, so the "trick" is that RL is not initialized. I get it. And why didn´t it work when both RL and LL were children of the first LL, like this: // // ? (sorry I cannot coment in different lines to order it so I put // instead) – serfe Sep 18 '13 at 08:11
  • No the trik was that if RL initialised it will override all inner Layouts, in that case that i suggest you Rl initialised by itself LL by itself. And nothing is overrided (but overlaped) – Lebedevsd Sep 18 '13 at 08:13
1

You could use the bringToFront() method of the View class.

SeekBar seeker = (SeekBar)findViewById(R.id.select_height);
seeker.bringToFront();

Alernatively you could use the sendToBack() function to put a view behind other views.

Also remember that a view's z-index is determined by the order in which the view is declared in the xml layout file.

I'd also suggest changing the camera preview layout and it's first child layout to be siblings. The one added last in the xml file will be on top.

Reasurria
  • 1,808
  • 16
  • 14