1

以下のモック グラフィックのような RelativeLayout ベースの Android UI が必要です。 ここに画像の説明を入力

以下は私のレイアウトxmlです:

<?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" >
    <!--  surface view that contains camera preview , and seats above @+id/linearLayoutToolbar -->
    <SurfaceView
        android:id="@+id/surfaceViewBarcodeScanner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <!--  LinearLayout that contains toolbar that is divided into 3 sections horizontally -->

    <LinearLayout
        android:id="@+id/linearLayoutToolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/surfaceViewBarcodeScanner"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/scanner_bottom_left" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/scanner_bottom_center_toolbar" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/scanner_bottom_right_landscape_button" />
    </LinearLayout>

</RelativeLayout>

Eclipse GUI パレットと独自の編集を使用しましたが、出力が期待したものではなく、SurfaceView が画面全体を覆っているように見え、下部の LinearLayout が表示されません。

Galaxy S3 デバイスでの現在の結果のスナップショット:

ここに画像の説明を入力

どんな助けでも感謝します、ありがとう。

4

3 に答える 3

0
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayoutForPreview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="5dp"
    android:orientation="vertical">

    <LinearLayout
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_width="match_parent">
        <SurfaceView
            android:id="@+id/surfaceViewBarcodeScanner"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/linearLayoutToolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:gravity="center"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/scanner_bottom_left" />
        </LinearLayout>
        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:gravity="center"
            android:layout_weight="2">
            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/scanner_bottom_center_toolbar" />
        </LinearLayout>
        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:gravity="center"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/scanner_bottom_right_landscape_button" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
于 2013-11-09T04:01:55.337 に答える
0

次のようにレイアウトを変更してみてください。

  • SurfaceView を定義し、その layout_above 値を前の手順で作成した線形レイアウトの ID に設定します。layout_alignParentTop を true に設定します。
  • 下の線形レイアウトを定義し、layout_alignParentBottom を true に設定します。

重要な部分のみを含むスマートなコード スニペット:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">

    <SurfaceView
        android:id="@+id/surfaceViewBarcodeScanner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/linearLayoutToolbar" />
    <LinearLayout
        android:id="@+id/linearLayoutToolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

これで問題が解決することを願っています。

于 2013-11-08T23:08:58.543 に答える