Android, surfacView to stretch entire width & desired height of screen , and unable to place TextView on surfaceView

StackOverflow https://stackoverflow.com/questions/19819703

質問

I want my layout to display surfaceView that covers all the screen width, also displays a TextView on top of the surfaceView, and another horizontal layout below the SurfaceView.

Below is the snapshot of my Eclipse android GUI designer:

enter image description here Below is the snapshot of actual GUI on my Galaxy S3 device:

enter image description here Below is the updated layout xml for this GUI/activity

    <?xml version="1.0" encoding="utf-8"?>


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:id="@+id/RelativeLayoutForPreview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- SurfaceView should cover all the screens width  -->
    <SurfaceView
        android:id="@+id/surfaceViewBarcodeScanner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <!-- TextView should be above SurfaceView  -->

    <!-- LinearLayout will contain linear toolbar   -->

    <TextView
        android:id="@+id/mytext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/mbackground2"
        android:gravity="center_horizontal"
        android:padding="20dip"
        android:textColor="@color/mytextcolor" />

</FrameLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="62dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:background="@drawable/scanner_bottom" >
</LinearLayout>

  </RelativeLayout>

Thanks

役に立ちましたか?

解決

I hope that this is what you want. I'm not sure if I understand you correctly, though.

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

    <!-- SurfaceView should cover all the screens width  -->
    <SurfaceView
        android:id="@+id/surfaceViewBarcodeScanner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <!-- TextView should be above SurfaceView  -->
    <TextView
        android:id="@+id/mytext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/mbackground2"
        android:gravity="center_horizontal"
        android:padding="20dip"
        android:textColor="@color/mytextcolor"/>

    <!-- LinearLayout will contain linear toolbar   -->
    <LinearLayout
        android:id="@+id/ScannerBottomToolbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginBottom="48dp"
        android:layout_marginLeft="77dp"
        android:orientation="vertical">

    </LinearLayout>
</FrameLayout>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top