問題: ImageButtons を適切な場所に表示したり、適切なサイズにしたりすることができないようです。
プラットフォーム: Android API 16 を使用した Eclipse
問題: 私の RelativeLayout は 600x800 で、ImageButtons は 194x64 ですが、エディターに配置すると、本来の 2 倍の大きさになります。画像へのリンクを参照してください。
私のXML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/main_portal_bg" >
<RelativeLayout
android1:layout_width="353dp"
android1:layout_height="758dp"
android1:layout_marginLeft="115dp"
android1:layout_marginTop="29dp"
android1:background="#000000" >
</RelativeLayout>
<ImageButton
android1:id="@+id/new_customer_button_selector"
android1:layout_width="194dp"
android1:layout_height="64dp"
android1:layout_marginTop="89dp"
android1:contentDescription="@string/back_button_desc"
android1:background="@drawable/new_customer_button_selector" />
<ImageButton
android1:id="@+id/returning_customer_button_selector"
android1:layout_width="194dp"
android1:layout_height="64dp"
android1:layout_alignParentLeft="true"
android1:layout_below="@+id/new_customer_button_selector"
android1:contentDescription="@string/back_button_desc"
android1:src="@drawable/returning_customer_button_selector" />
<ImageButton
android1:id="@+id/redeem_coupon_button_selector"
android1:layout_width="194dp"
android1:layout_height="64dp"
android1:layout_alignParentLeft="true"
android1:layout_below="@+id/returning_customer_button_selector"
android1:contentDescription="@string/back_button_desc"
android1:src="@drawable/redeem_coupon_button_selector" />
<ImageButton
android1:id="@+id/info_button_selector"
android1:layout_width="194dp"
android1:layout_height="64dp"
android1:layout_alignParentLeft="true"
android1:layout_below="@+id/redeem_coupon_button_selector"
android1:contentDescription="@string/back_button_desc"
android1:src="@drawable/info_button_selector" />
</RelativeLayout>
調査: FitXY の ScaleType を使用し、MaxHeight と MinHeight を設定し、android:src の代わりに android:background を使用しようとしました。小さくすることができた唯一の方法は、グラフィカル エディターを使用して、Shift キーを押しながら右下隅をドラッグしてサイズを変更することです。残念なことに、それらは自動的にレイアウトの下部に配置され、移動しようとすると元のサイズに戻り、他のすべてのボタンがレイアウトの周りでシャッフルされます。XML を編集しても、その方法の一部しか得られません。
質問: グラフィカル エディターでボタンを移動しようとするたびに、他のすべてのボタンが画面上で一見ランダムなパターンでシャッフルされます。なぜこれが起こるのですか?
幅 194 dp、高さ 64 dp に設定しました。これらの値を変更しても何も起こりません。これが ImageButton の実際の幅と高さに影響しないのはなぜですか?
グラフィカル エディターを使用して Shift キーを押しながら角をドラッグしてボタンのサイズを変更すると、XML の幅と高さの値は変更されず、余白が追加されるだけです。以下の結果の XML を参照してください。
<ImageButton
android1:id="@+id/new_customer_button_selector"
android1:layout_width="194dp"
android1:layout_height="64dp"
android1:layout_alignParentBottom="true"
android1:layout_alignRight="@+id/returning_customer_button_selector"
android1:layout_marginBottom="408dp"
android1:layout_marginRight="86dp"
android1:layout_marginTop="89dp"
android1:background="@drawable/new_customer_button_selector"
android1:contentDescription="@string/back_button_desc" />
これが私の最終目標です:
どうすればそこに行けるか教えてください。この単純なことはもっと簡単なはずです。