0

ボタンの配置に問題があります。アプリの起動時にカメラが開く (カスタマイズされた) アプリを開発しています。レイアウトに 2 つのボタンを追加しました。問題は、ボタンを調整できないことです。キャプチャ ボタンが中央の下部に、アップロード ボタンが右下に配置されるようにボタンを配置します。次のコードを使用しています。

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

<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>

</FrameLayout>
  <Button
      android:id="@+id/button_upload"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="0dp"
      android:text="Upload"
       />

  <Button
      android:id="@+id/button_capture"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="0dp"
      android:text="Capture" />


</RelativeLayout>

LinearLayout も試しました。誰が私がどこで間違いを犯しているのか教えてもらえますか? 前もって感謝します。

4

3 に答える 3

1

これを試してください...

android:layout_centerHorizontal="true"

ボタンタグで

于 2013-02-20T17:46:35.103 に答える
1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 >

  <FrameLayout
      android:id="@+id/camera_preview"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_alignBottom="@+id/button_upload"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_weight="1" >

  </FrameLayout>

  <Button
      android:id="@+id/button_upload"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:text="Upload" />

  <Button
      android:id="@+id/button_capture"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_marginRight="55dp"
      android:layout_toLeftOf="@+id/button_upload"
      android:text="Capture" />

</RelativeLayout>`enter code here`
于 2013-02-20T17:54:28.170 に答える
0

だから私はこれがこのようにできると考えました。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="0dp"
    android:background="#A9A9A9"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/camera_preview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:layout_above="@+id/button_capture"
    />
  <Button
      android:id="@+id/button_capture"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:text="Capture" />

  <Button
      android:id="@+id/button_upload"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentBottom="true"
      android:text="Upload" />

  </RelativeLayout>
于 2013-02-20T18:06:49.830 に答える