2

Eclipse のグラフィカル レイアウト エディターは、多くの場合 (通常は?)、物理デバイスやエミュレーターと同じ方法でレンダリングしないことに気付きました。私は通常それを扱うことができます。しかし、なぜそんなに大きな違いがあるのか​​ わからない状況があります。さらに重要なことに、ターゲットデバイスでレイアウトに必要なものを取得する方法がわかりません.

カスタム グラフィック ファイルをボタンとして使用するカスタム ImageButton ウィジェットを使用しようとしています。私は単純に、ボタンが親のレイアウトを埋めるようにしたいだけです。デザイナーでは、私が思うように見えます。しかし、デバイスで実行すると、ボタンが小さすぎます。これは、私がテストしている Droid X をエミュレートするように設定されたデバイスを使用して、デザインがどのように見えるかです。

http://pozzy.com/consulting/LayoutDesignInEclipse.PNG

これは、私の Droid X で実行しているときの画面のスクリーン キャプチャです。

http://pozzy.com/consulting/ScoreEntryDroidXScreenCapture.png

コードを削除しようとしましたが、まだ多数のボタン イメージ ファイルに依存しています。レイアウト 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">

     <LinearLayout
         android:id="@+id/scoreEntryPlayersAndMainEntry"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal" >

         <LinearLayout
             android:id="@+id/scoreEntryPlayers"
             android:layout_width="0dp"
             android:layout_height="fill_parent"
             android:layout_weight=".5"
             android:orientation="vertical"
             android:paddingBottom="4dp"
             android:paddingTop="4dp"
             android:paddingLeft="4dp" >                                             
         </LinearLayout>

         <LinearLayout
             android:id="@+id/scoreEntryMainEntry"
             android:layout_width="0dp"
             android:layout_height="fill_parent"
             android:layout_weight=".5"
             android:maxWidth="100dp"
             android:orientation="vertical"
             android:paddingBottom="4dp"
             android:paddingLeft="4dp"
             android:paddingRight="4dp"
             android:paddingTop="4dp" >

             <LinearLayout android:id="@+id/scoreEntryPreviousHoleNumberNextRow"
                 android:orientation="horizontal"
                   android:background="@drawable/score_entry_background_top"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_weight=".1"
                 android:gravity="center|top" >

                 <ImageButton
                     android:id="@+id/previousHoleButton"
                     android:layout_width="0dp"
                     android:layout_height="fill_parent"
                    android:layout_weight="2"
                     android:layout_margin="5dp"
                    android:scaleType="fitCenter"
                     android:background="@null"
                     android:contentDescription="Previous Hole"
                     android:src="@drawable/score_entry_prev" />

                 <TextView
                     android:id="@+id/holeNumber"
                     android:layout_width="0dp"
                     android:layout_height="match_parent"
                     android:layout_weight="1"
                     android:background="@null"
                     android:paddingTop="20dp"
                     android:text="##"
                     android:textColor="#FFFFFF"
                     android:textSize="24sp"
                     android:textStyle="bold" />

                    <ImageButton
                        android:id="@+id/nextHoleButton"
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                    android:layout_weight="2"
                        android:layout_margin="5dp"
                        android:scaleType="fitCenter"
                        android:background="@null"
                        android:contentDescription="Next Hole"
                        android:src="@drawable/score_entry_next" />
             </LinearLayout>

             <LinearLayout
                 android:id="@+id/scoreEntryCurrentScore"
                   android:background="@drawable/score_entry_background_middle"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_weight=".8" >

                 <FrameLayout
                     android:id="@+id/scoreEntryScoreOverlays"
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content" >
                     <LinearLayout
                         android:visibility="invisible"
                         android:id="@+id/scoreEntryPlayerScoreLayout"
                         android:layout_width="fill_parent"
                         android:layout_height="wrap_content"
                         android:orientation="vertical" >

                         <TextView
                             android:id="@+id/currentPlayer"
                             android:layout_width="fill_parent"
                             android:layout_height="wrap_content"
                             android:layout_margin="10dp"
                             android:gravity="center"
                             android:text="Player Name"
                             android:textColor="#aaaaaa"
                             android:textSize="16sp"
                             android:textStyle="italic" />

                         <TextView
                             android:id="@+id/currentScore"
                             android:layout_width="fill_parent"
                             android:layout_height="fill_parent"
                             android:text="99"
                             android:gravity="center"
                             android:layout_gravity="bottom"
                             android:textColor="#ff0000"
                             android:textSize="100sp"
                             android:textStyle="bold|italic" />
                     </LinearLayout>
                </FrameLayout>
             </LinearLayout>

             <LinearLayout
                 android:id="@+id/scoreEntryScoreDownUpRow"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:background="@drawable/score_entry_background_bottom"
                 android:gravity="bottom"
                 android:layout_weight=".1"
                 android:orientation="horizontal" >
                 <ImageButton
                     android:id="@+id/scoreDownButton"
                     android:layout_width="0dp"
                     android:layout_height="fill_parent"
                     android:layout_margin="5dp"
                     android:layout_weight="1"
                     android:background="@null"
                     android:scaleType="fitCenter"
                     android:src="@drawable/score_entry_minus" />


                 <ImageButton
                     android:id="@+id/scoreUpButton"
                     android:layout_width="0dp"
                     android:layout_height="fill_parent"
                     android:layout_margin="5dp"
                     android:layout_weight="1"
                     android:background="@null"
                     android:scaleType="fitCenter"
                     android:src="@drawable/score_entry_plus" />

             </LinearLayout>

         </LinearLayout>
     </LinearLayout>     
</RelativeLayout>

それぞれの領域を満たすボタンを取得する方法を理解する上での助けをいただければ幸いです。

4

1 に答える 1

0

私はまったく同じ問題を抱えていて、両方の場所に合うように毎回それを操作することによってそれを回避しなければなりませんでした。それは悲しいことです。Eclipseグラフィックビジュアライザーは時々本当にひどいです。多くの人がそれはかなり良いと言っているので、私はhttp://www.droiddraw.org/
を 試しましたが、どういうわけか、ビジュアライザーと実際のデバイスで表示されるものの間にギャップがあるようです。経験則では、このhttp://developer.android.com/training/multiscreen/screensizes.htmlに従って手紙を読み、試してみてください。Droid Drawは、Eclipseよりもうまく機能すると思います。上記の開発リンクをたどり、たとえばDroidDrawを使用すると理想的に機能するはずです。

于 2012-06-20T06:31:00.817 に答える