1

どうすればいいのかわからないので、時間を無駄にしているだけです。基本的には、ユーザーが指で好きなものを描くことができるカスタム入力ビューが必要です。その下に、重ならない2つ(またはそれ以上)のボタンを配置します。カスタムビューの上部。幅と高さのハードコーディングを避けようとしているので、ボタンをコンテンツに折り返し、カスタムビューが残りの高さを占めるように指定する方法はありますか?すべてのボタンの高さが同じであると予想しているので、そのうちの1つの高さを基準として使用すると、なんとか機能するはずです...

これが私の現在のレイアウトです:

<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"
    tools:context=".MainActivity" >

    <com.example.myapp.DrawView
        android:id="@+id/drawView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <Button
        android:id="@+id/buttonSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="@string/save" />

    <Button
        android:id="@+id/buttonQuery"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="@string/query" />

</RelativeLayout>

厄介な方法でハックすることなく、私が望むことを簡単に達成することは実際に可能ですか?

4

2 に答える 2

1

Buttonsカスタムビューを:の上に配置します。

<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"
    tools:context=".MainActivity" >

   <Button
        android:id="@+id/buttonSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="@string/save" />

    <Button
        android:id="@+id/buttonQuery"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="@string/query" />

    <com.example.myapp.DrawView
        android:id="@+id/drawView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" 
        android:layout_above="@id/buttonSave" />

</RelativeLayout>

高さButtonsが等しいかどうかわからない場合は、それらを別のレイアウト(など)でラップしてから、そのラッパーの上LinearLayoutにカスタムを配置する必要があります。View

于 2012-07-31T12:42:12.837 に答える
0

いくつかのレイアウトにボタンを配置します。

<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"
tools:context=".MainActivity" >

<com.example.myapp.DrawView
    android:id="@+id/drawView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />


    <RelativeLayout android:id="@+id/button_layout"
              ........  
              android:layout_alignParentBottom="true"
    >
              ....
              your buttons
              .....
    </RelativeLayout>  
</RelativeLayout>
于 2012-07-31T12:46:38.797 に答える