-1

xmlファイルにボタンを配置するときに問題が発生しました。

これは私のグラフィックレイアウトです

ここで必要なのは、下部にある[OK]ボタンが、最後から2番目のストリップにあるマイレージ編集テキストの下に表示されるようにすることです。ボタンの前にスクロールビューを使用しています。また、私は背景として単一の画像を使用しています。

アプリケーションのすべてのボタンが最後から2番目のストリップ(灰色)にのみ表示されるのはどうしてですか?レイアウトの残りの部分は、中間(つまり、上部の灰色のストリップと下部の灰色のストリップの間)に配置する必要があります。

'dp'でmargin_topまたはmargin_bottomを使用してみましたが、他のすべての電話でボタンのレイアウトが変更され、正しく機能しませんでした。これが私のコード(.xmlファイル)です:

     <?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:background="@drawable/menu"
    android:padding="10dp">

    <ScrollView
        android:id="@+id/scv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="105dp"
        android:layout_marginBottom="105dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="Year"
        android:inputType="date" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignRight="@+id/editText1"
        android:layout_below="@+id/editText1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp" />

    <Spinner
        android:id="@+id/spinner2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/spinner1"
        android:layout_alignRight="@+id/spinner1"
        android:layout_below="@+id/spinner1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp" />

    <Spinner
        android:id="@+id/spinner3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/spinner2"
        android:layout_alignRight="@+id/spinner2"
        android:layout_below="@+id/spinner2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/spinner3"
        android:layout_below="@+id/spinner3"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="Mileage"
        android:inputType="number" />
  </RelativeLayout>
         </ScrollView>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:text="OK" />

    </RelativeLayout>
4

2 に答える 2

0

ボタンxmlについては、試してください

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/scv"
        android:layout_centerHorizontal="true"
        android:text="OK" />

android:layout_marginTop="5sp"必要に応じて、値を変更して追加できます 。これにより、スクロールビューの下にボタンが配置されます。

于 2013-03-20T10:04:37.053 に答える
0

Android では、完全なレイアウトに 1 つの画像を使用しないでください。非常に多くの異なる画面サイズがあるため、それはうまく機能しません。

グラフィックを部分的に切り取り、画面サイズに応じて収まるように伸ばすことをお勧めします. 独自のコードのコピーペーストが不十分であり、グラフィックをどのように表示したいかの視覚化の欠如に基づいて、これ以上のことを支援することは実際には不可能です.

于 2013-03-20T09:34:03.167 に答える