1

私はAndroidにかなり慣れておらず、レイアウトに問題があります。以下は、私がレイアウトをどのように見せたいかについての概算です。(ユーザーが下にスクロールして表示できるように、最初はリストを画面の下に配置します。)ただし、現在のコードでは、左側のすべてのビューが画面の半分ではなく4分の1しか占めていません。 、示されているように、すべての幅をfill_parentに設定していますが。

また、このレイアウトは私のカスタムビューの座標系を台無しにしているようです。通常、これはそれほど問題にはなりませんが、この場合、私はそのビューを使用して絵を描き、絵が間違った場所に配置されてしまいます。誰かがこれらの問題を解決する方法を知っていますか?代替テキスト

これが私のコードです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TableRow>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:orientation="vertical"
android:layout_width="fill_parent">
<TableRow>
 <TextView android:text="Resultant Force" android:id="@+id/resForceTitle"
  android:textSize="25dip" android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:padding="3dip"
  android:gravity="center" android:layout_span="2" />
</TableRow>
<TableRow>
 <TextView android:id="@+id/magText" android:text="Magnitude (N) ="
  android:textSize="15dip" android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:padding="3dip"
  android:gravity="center_vertical" android:layout_span="2" />
</TableRow>
<TableRow>
 <EditText android:id="@+id/magnitude" android:inputType="numberDecimal"
  android:layout_width="fill_parent" android:padding="3dip"
  android:layout_height="fill_parent" android:layout_span="2" />
</TableRow>
<TableRow>
 <TextView android:id="@+id/dirText" android:text="Angle (deg) ="
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:textSize="15dip" android:gravity="center_vertical"
  android:layout_span="2" />
</TableRow>
<TableRow>
 <EditText android:id="@+id/direction" android:inputType="numberDecimal"
  android:layout_height="fill_parent" android:padding="3dip"
  android:layout_width="fill_parent" android:layout_span="2" />
</TableRow>
<TableRow>
 <Button android:id="@+id/pushButton" android:text="Add Force"
  android:layout_height="fill_parent" android:padding="3dip"
  android:layout_width="fill_parent" />
 <Button android:id="@+id/clearButton" android:text="Clear"
  android:layout_height="fill_parent" android:padding="3dip"
  android:layout_width="fill_parent" />
</TableRow>
</TableLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<android.physicsengine.AxisDrawing
 android:id="@+id/image" android:layout_width="fill_parent"
 android:layout_height="fill_parent" />
</FrameLayout>
</TableRow>
</TableLayout>
<ListView android:id="@android:id/list" android:layout_height="wrap_content"
android:padding="3dip" android:layout_width="fill_parent"
android:clickable="false" />
<TextView android:id="@android:id/empty" android:text="Add Forces to List Components"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textSize="15dip" android:gravity="center_vertical" />
</LinearLayout>
4

2 に答える 2

4

XMLの外観からは、fill_parentの意味を誤解しているように見えます。それは「私の親と同じくらい大きくなる」という意味です。また、なぜ2つのネストされたTableLayoutを使用しているのですか?画面を2つに均等に分割するには、水平のLinearLayoutを使用し、各子(TableLayoutとカスタムビュー)に幅0dip、layout_weight1を指定する必要があります。

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TableLayout
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content">
            ...
    </TableLayout>
    <android.physicsengine.AxisDrawing
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content" />
</LinearLayout>
于 2011-01-23T02:36:20.380 に答える
0

これは、EditTextsにandroid:layout_span="2"と入力したためです。これらを削除すると、すべてがより正常に動作します。

次に、たとえばEditTextの幅を200dpに設定することで、左側を制御できます。EditTextの右マージンを使用して、左側の列を制御することもできます。

カスタムビューキャンバスの座標は、右上隅の0,0から始まります。

于 2011-01-23T02:45:38.647 に答える