0

画像アプリケーションを作成しようとしていますが、xml ファイルの 1 つにボタンと画像ビューがあります。画像ビューにデフォルトの画像があります。一部のデバイスでは、小さすぎたり大きすぎたりします。画像が画面の外に出たり、ボタンの上に出たりしたくありません。どうすればいいですか?ここにxmlコードがあります

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >



<Button
    android:id="@+id/btakePic"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="Take Picture" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="400dp"
    android:gravity="center"
    android:src="@drawable/android_syh" />

</RelativeLayout>
4

1 に答える 1

0

多分これはあなたが望むものです:

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

    <Button
        android:id="@+id/btakePic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="Take Picture" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/btakePic"        
         />

</RelativeLayout>

android:gravity="center"あなたが持っているので持っている必要はありませんandroid:layout_width="fill_parent"

お役に立てば幸いです。

于 2012-07-13T20:54:53.920 に答える