1
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:id="@+id/mainlayout"    
    android:layout_width="fill_parent"     
    android:layout_height="450dp"     
    android:background="#f8f9fe" >      

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

        <LinearLayout                  
            android:id="@+id/extremelysorry"                  
            android:layout_width="fill_parent"                  
            android:layout_height="wrap_content"                 
            android:layout_marginLeft="10dp"                    
            android:layout_marginRight="20dp"                        
            android:layout_marginTop="30dp"            
            android:background="@drawable/pressicon"        
            android:orientation="vertical" >

            <TextView     
                android:id="@+id/extremelysorry1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="1dp"
                android:padding="5dip"
                android:text="  &quot;We are extremely sorry, request your valuable ."
                android:textColor="#FFFFFF"
                android:textSize="20dip"
                android:textStyle="bold" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/layout_name"
                android:layout_width="fill_parent"
                android:layout_height="35dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="20dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/pressicon"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/signetno"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="1dp"
                    android:padding="5dip"
                    android:text=" Please enter your Loyalty Card No/Name,Mobile No/Name "
                    android:textColor="#FFFFFF"
                    android:textSize="20dip"
                    android:textStyle="bold" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/LinearLayout03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="70dp"
                android:orientation="vertical" android:layout_marginTop="30dp">

                <LinearLayout
                    android:id="@+id/LinearLayout02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp" >

                    <LinearLayout
                        android:layout_width="250dp"
                        android:layout_height="wrap_content"
                        android:background="@drawable/labelbg" >

                        <TextView
                            android:id="@+id/loyaltyLable"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="7dp"
                            android:layout_marginTop="3dp"
                            android:padding="5dp"
                            android:text="Membership Card No."
                            android:textColor="#FFFFFF"
                            android:textSize="20dp" />

                    </LinearLayout>

                    <EditText
                        android:id="@+id/ed_cardno"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_marginLeft="50dp"
                        android:layout_weight="1"
                        android:background="@drawable/textbox_n"
                        android:ems="10"
                        android:hint="Touch here to enter"
                        android:imeOptions="actionDone|flagNoExtractUi"
                        android:inputType="number"
                        android:paddingLeft="5dp"
                        android:singleLine="true"
                        android:textSize="20dp" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/layout_age"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="5dp" >

                    <LinearLayout
                        android:layout_width="250dp"
                        android:layout_height="wrap_content"
                        android:background="@drawable/labelbg" >

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="7dp"
                            android:layout_marginTop="3dp"
                            android:padding="5dp"
                            android:text="Name"
                            android:textColor="#FFFFFF"
                            android:textSize="20dp" />

                    </LinearLayout>

            <EditText
                android:id="@+id/ed_name"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="50dp"
                android:layout_weight="1"
                android:autoText="true"
                android:background="@drawable/textbox_n"
                android:ems="10"
                android:hint="Touch here to enter"
                android:imeOptions="actionDone|flagNoExtractUi"
                android:paddingLeft="5dp"
                android:singleLine="true"
                android:textSize="20dp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/layout_emailid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="5dp" >

            <LinearLayout
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:background="@drawable/labelbg" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="7dp"
                    android:layout_marginTop="3dp"
                    android:padding="5dp"
                    android:text="Mobile No"
                    android:textColor="#FFFFFF"
                    android:textSize="20dp" />

            </LinearLayout>

            <EditText
                android:id="@+id/ed_mobileno"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="50dp"
                android:layout_weight="1"
                android:background="@drawable/textbox_n"
                android:ems="10"
                android:hint="10digit Mobile number"
                android:imeOptions="actionDone|flagNoExtractUi"
                android:numeric="integer"
                android:paddingLeft="5dp"
                android:phoneNumber="true"
                android:singleLine="true"
                android:textSize="20dp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/layout_cardno"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="5dp" >

            <LinearLayout
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:background="@drawable/labelbg" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="7dp"
                    android:layout_marginTop="3dp"
                    android:padding="5dp"
                    android:text="Email ID"
                    android:textColor="#FFFFFF"
                    android:textSize="20dp" />

            </LinearLayout>

            <EditText
                android:id="@+id/ed_emailid"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="50dp"
                android:layout_weight="1"
                android:background="@drawable/textbox_n"
                android:ems="10"
                android:hint="Touch here to enter"
                android:imeOptions="actionDone|flagNoExtractUi"
                android:inputType="textEmailAddress"
                android:paddingLeft="5dp"
                android:singleLine="true"
                android:textSize="20dp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/layout_comeagain"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="5dp" >

        </LinearLayout>

        <LinearLayout
            android:id="@+id/LinearLayout01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

                <Button
                android:id="@+id/back"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:focusable="true"
                android:background="@drawable/back_button"
                android:textColor="#ff29549f" />

                <Button
                android:id="@+id/comment_next"
                android:layout_width="wrap_content"
                android:layout_height="37dp"
                android:layout_marginLeft="420dp"
                android:background="@drawable/next_button"
                android:focusable="true"
                android:textColor="#ff29549f" />

            <Chronometer
                android:id="@+id/start_quiz_time1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="3.19"
                android:textSize="15sp"
                android:visibility="invisible" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="30dp"
        android:background="@drawable/pressicon"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/manadatory"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="1dp"
            android:padding="5dip"
            android:text="  *Mandatory: The information is confidential &amp; will not"
            android:textColor="#FFFFFF"
            android:textSize="20dip" />

        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

これは私のコードですが、複数の画面をサポートしていません。ウィジェットがずれます。

このコードを任意のタブレットで実行するように変更する方法は、画面サイズと密度が異なるすべてのタブレットで同じように見えますか?

4

3 に答える 3

1

これは、レイアウトの高さと幅のサイズを dp で設定しているためです。

レイアウトが画面サイズで調整されるように、重量についてもっと調べる必要があります。

于 2012-09-19T11:52:26.493 に答える
1

以下のコードを Androidmanifest.xml ファイルに書き込みます

<supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true" />

詳細については、以下のリンクを参照してください。

画面サイズ対応

于 2012-09-19T11:52:41.270 に答える
1


複数のデバイスで実行する必要があるアプリを設計する場合、注意が必要な 2 つの重要なパラメーターがあります。

  • サイズ(デバイスの物理サイズ)
  • デバイスの密度

サイズ: Android のデバイスのサイズは、一意の物理値ではなく、範囲として定義されます。
これらは、small、normal、large、および xlarge です。

密度: 密度も範囲として定義されます。
これらは、ldpi、mdpi、hdpi、および xhdpi です。

ここに画像の説明を入力

サイズを処理するには、サイズのカテゴリごとに 1 つずつ、複数のレイアウトを使用する必要があり、レイアウトごとにビューの高さと幅に異なる dp 値を使用する必要があります。同じであること。

密度を処理するには、異なる画面密度に対して異なるドローアブルを使用する必要があります。つまり、異なる密度のドローアブルを異なるドローアブル フォルダーに配置する必要があります。
例:
これらは特定のドローアブルの解像度です

  • 低密度の場合は 36x36 (drawable-ldpi に配置)
  • 中密度の場合は 48x48 (drawable-mdpi に配置)
  • 高密度の場合は 72x72 (drawable-hdpi に配置)
  • 超高密度の場合は 96x96 (drawable-xhdpi に配置)

この解像度のバリエーションの比率は 3:4:6:8(ldpi:mdpi:hdpi:xhdpi) です。

詳細については、この Android 開発者のリンクを参照してください:
http://developer.android.com/guide/practices/screens_support.html

于 2012-09-19T12:53:49.187 に答える