Question

I need same as I attached image file Its Camera Preview Screen : I want to design two transparent layout over framelayout so it looks like this, but when I run it show only camera screen(Framelayout). It not showing two relative layouts.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/camera_preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:layout_gravity="top"
        android:padding="15dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="01"
            android:textColor="@color/White" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/textView1"
            android:layout_marginTop="5dp"
            android:text="Status:"
            android:textColor="@color/White" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/textView1"
            android:layout_marginRight="78dp"
            android:src="@drawable/heart" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/textView2"
            android:layout_alignLeft="@+id/imageView3"
            android:layout_marginTop="10dp"
            android:src="@drawable/view" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/imageView3"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/imageView4"
            android:text="125 Likes"
            android:textColor="@color/White" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/textView2"
            android:layout_toRightOf="@+id/textView2"
            android:text="STREAMING" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView3"
            android:layout_alignTop="@+id/imageView4"
            android:text="24 Viewers"
            android:textColor="@color/White" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#77000000"
        android:layout_gravity="bottom"
        android:padding="10dp" >

        <Button
            android:id="@+id/button_capture"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/camera_record"
            android:textColor="@color/White" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="50dp"
            android:src="@drawable/view_video_big" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="50dp"
            android:src="@drawable/swipe_camera" />
    </RelativeLayout>

</FrameLayout>
Was it helpful?

Solution

Add ids to the two RelativeLlayouts in layout file..

and get the view object by like this

    RelativeLayout layout1=(RelativeLayout) findViewById(R.id.topRelativeLayout);
    RelativeLayout layout2=(RelativeLayout) findViewById(R.id.bottomRelativeLayout);

and add this line in your onCreate and test once..

    layout1.bringToFront();
    layout2.bringToFront();

OTHER TIPS

Try this first of all you have to set your background image to FrameLayout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/camera_preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" 
    android:background="@drawable/ic_launcher"
     >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:padding="15dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="01"
            android:textColor="@color/White" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/textView1"
            android:layout_marginTop="5dp"
            android:text="Status:"
            android:textColor="@color/White" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/textView1"
            android:layout_marginRight="78dp"
            android:src="@drawable/heart" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/textView2"
            android:layout_alignLeft="@+id/imageView3"
            android:layout_marginTop="10dp"
            android:src="@drawable/view" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/imageView3"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/imageView4"
            android:text="125 Likes"
            android:textColor="@color/White" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/textView2"
            android:layout_toRightOf="@+id/textView2"
            android:text="STREAMING" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView3"
            android:layout_alignTop="@+id/imageView4"
            android:text="24 Viewers"
            android:textColor="@color/White" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#77000000"
        android:layout_gravity="bottom"
        android:visibility="visible"
        android:padding="10dp" >

        <Button
            android:id="@+id/button_capture"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/camera_record"
            android:textColor="@color/White" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="50dp"
            android:src="@drawable/view_video_big" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="50dp"
            android:src="@drawable/swipe_camera" />
    </RelativeLayout>

</FrameLayout>

or follow this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top