0

私は最初の堅牢な Android アプリケーションを作成していますが、メイン フォームにコントロールを配置しようとして多くの問題を抱えています。

4 つのテキストビュー、1 つのチェックボックス、1 つのボタンがあります。Galaxy Nexus (4.65 インチ) でデバッグしますが、4 インチのフォーム画面サイズを使用しているため、アプリで小さな画面サイズに対応できます。

テキストビューまたはボタンを移動しようとすると、他のすべてのコントロールが別の場所に移動するように見えます。また、ボタンの配置の半分は、デバッグ時に強制的に閉じることができます。コントロールをレイアウトするのはこれほど難しいことではないように思えますが、やはり私はwinformとほとんどasp.netから来ていません。

アドバイスをいただければ幸いです。

編集:xmlを追加しました。ラップの幅/高さ、親の一致、およびカスタム サイズをすべて同じ結果で試しました。多分私のコントロールは、asp.net のようなある種のテーブルにあるはずですか?

<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"
android:background="#808080" >

<Button
    android:id="@+id/btnOK"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="38dp"
    android:background="#FFFFFF"
    android:onClick="onOKclicked"
    android:text="@string/OkButton" />

<CheckBox
    android:id="@+id/chkShow"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btnOK"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="40dp"
    android:text="@string/DoNotShow"
    android:textColor="#FFFFFF"
    android:textSize="16dp" />

<TextView
    android:id="@+id/txt3G"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/chkShow"
    android:layout_marginBottom="112dp"
    android:text="@string/Description3G"
    android:textColor="#FFFFFF"
    android:textSize="16dp" />

<TextView
    android:id="@+id/txt4G"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txt3G"
    android:layout_alignLeft="@+id/chkShow"
    android:layout_marginBottom="36dp"
    android:text="@string/Description4G"
    android:textColor="#FFFFFF"
    android:textSize="16dp" />

<TextView
    android:id="@+id/txtDescription"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="20dp"
    android:layout_marginTop="14dp"
    android:text="@string/Instructions1"
    android:textColor="#FFFF00"
    android:textSize="16dp" />

<TextView
    android:id="@+id/txtBattery"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/txt3G"
    android:layout_alignBottom="@+id/txt3G"
    android:layout_alignLeft="@+id/btnOK"
    android:layout_marginLeft="30dp"
    android:text="@string/DescriptionBattery"
    android:textColor="#FFFF00"
    android:textSize="14dp"
    android:textStyle="italic" />

</RelativeLayout>
4

1 に答える 1

0

相対レイアウトで作業しているため、ボタンを移動すると、そのボタンに相対的に配置されたコントロールのレイアウトが壊れます。

デバッグの問題が発生する理由はわかりません。スタック トレースまたは役立つ情報を投稿していただけますか。

于 2012-11-04T21:11:12.430 に答える