Как создать дизайн на 10-дюймовом планшете только в портретном режиме в Android?

#java #android #xml

#java #Android #xml

Вопрос:

введите описание изображения здесьМне нужно разработать приложение для 10-дюймовой вкладки в Android.Но когда я запускаю приложение , дизайн становится размытым или нечетким .Я не знаю почему. Я также объявил манифест android:screenOrientation="portrait" in .Как правильно спроектировать и в чем я ошибаюсь xml file .Заранее благодарю.

Вот мой код XML-файла

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white" >

        <ImageView
            android:id="@ id/imageLogoBBT"
            android:layout_width="400dp"
            android:layout_height="80dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:contentDescription="@string/desc"
            android:scaleType="fitXY"
            android:src="@drawable/banya_tree_logo" />

        <ImageView
            android:id="@ id/imageButtonBack"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="15dp"
            android:layout_marginTop="18dp"
            android:contentDescription="@string/desc"
            android:scaleType="fitCenter"
            android:src="@drawable/back_img" />

        <RelativeLayout
            android:id="@ id/relImagLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@ id/imageLogoBBT"
            android:background="@drawable/inner_back"
            android:padding="5dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#E6E9E9" >

                <TextView
                    android:id="@ id/textViewTitle"
                    android:layout_width="fill_parent"
                    android:layout_height="30dp"
                    android:layout_marginTop="5dp"
                    android:gravity="center"
                    android:text="@string/APPLICATION_FOR_FUND_TRANSFER"
                    android:textColor="#32241F"
                    android:textSize="25sp"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    android:id="@ id/APPLICANTS_INFORMATION_Detail"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@ id/textViewTitle"
                    android:layout_marginLeft="10dp"
                    android:text="@string/APPLICANTS_INFORMATION"
                    android:textColor="#32241F"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <LinearLayout
                    android:id="@ id/linearScroll"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_above="@ id/lastrowLayout"
                    android:layout_below="@ id/APPLICANTS_INFORMATION_Detail"
                    android:baselineAligned="false"
                    android:orientation="horizontal" >

                    <ScrollView
                        android:id="@ id/scrollFormOne"
                        android:layout_width="400dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.25"
                        android:baselineAligned="false"
                        android:orientation="vertical"
                        android:padding="2dp" >

                        <LinearLayout
                            android:id="@ id/linearlayout_One"
                           android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:baselineAligned="false"
                            android:orientation="vertical" >

                            <LinearLayout
                                android:id="@ id/linearlayout_textView"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:baselineAligned="false"
                                android:orientation="horizontal" >

                                <TextView
                                    android:layout_width="0dp"
                                    android:layout_height="30dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.10"
                                    android:gravity="left"
                                    android:text="@string/title"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />

                                <TextView
                                    android:layout_width="0dp"
                                    android:layout_height="30dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.25"
                                    android:gravity="left"
                                    android:paddingLeft="5dp"
                                    android:text="@string/last_name"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />

                                <TextView
                                    android:layout_width="0dp"
                                    android:layout_height="30dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.25"
                                    android:gravity="left"
                                    android:paddingLeft="5dp"
                                    android:text="@string/first_name"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />
                            </LinearLayout>

                            <LinearLayout
                                android:id="@ id/linearlayout_EditText"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="7dp"
                                android:baselineAligned="false"
                                android:orientation="horizontal" >

                                <Spinner
                                    android:id="@ id/gps_spinnertitleName"
                                    android:layout_width="0dp"
                                    android:layout_height="40dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.10"
                                    android:background="@drawable/button_shape"
                                    android:gravity="center"
                                    android:inputType="text"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />

                                <EditText
                                    android:id="@ id/gps_edittextLastName"
                                    android:layout_width="0dp"
                                    android:layout_height="40dp"
                                    android:layout_marginLeft="5dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.25"
                                    android:background="@drawable/button_shape"
                                    android:gravity="left"
                                    android:inputType="text"
                                    android:paddingLeft="5dp"
                                    android:paddingTop="5dp"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />

                                <EditText
                                    android:id="@ id/gps_editTextFirst"
                                    android:layout_width="0dp"
                                    android:layout_height="40dp"
                                    android:layout_marginLeft="5dp"
                                    android:layout_marginTop="5dp"
                                    android:layout_weight="0.25"
                                    android:background="@drawable/button_shape"
                                    android:gravity="left"
                                    android:inputType="text"
                                    android:paddingLeft="5dp"
                                    android:paddingTop="5dp"
                                    android:textColor="#241444"
                                    android:textSize="19sp"
                                    android:textStyle="normal" />
                            </LinearLayout>


                        </LinearLayout>
                    </ScrollView>

                    <ScrollView
                        android:id="@ id/scrollFrorm_Two"
                         android:layout_width="400dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.25"
                        android:baselineAligned="false"
                        android:orientation="vertical"
                        android:padding="2dp" >

                        <LinearLayout
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:baselineAligned="false"
                            android:orientation="vertical" >

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:text="@string/Beneficiary_Address"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Beneficiary_Address"
                                android:layout_width="fill_parent"
                                android:layout_height="80dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="textMultiLine"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/Beneficiary_Account_No"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Beneficiary_Account_No"
                                android:layout_width="fill_parent"
                                android:layout_height="40dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="number"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/Beneficiary_Bank_Name"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Beneficiary_Bank_Name"
                                android:layout_width="fill_parent"
                                android:layout_height="40dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="text"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/Beneficiary_Bank_Address"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Beneficiary_Bank_Address"
                                android:layout_width="fill_parent"
                                android:layout_height="80dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="textMultiLine"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/BIC_Chips_ID_BSB_Code_Fed_Wire_ABA_Sort_Code"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_BIC_Chips_ID_BSB"
                                android:layout_width="fill_parent"
                                android:layout_height="40dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="text"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/Intermediary_Bank_Name"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Intermediary_Bank_Name"
                                android:layout_width="fill_parent"
                                android:layout_height="40dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="text"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />

                            <TextView
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:text="@string/Intermediary_Bank_Address"
                                android:textColor="#241444"
                                android:textSize="19sp"
                                android:textStyle="normal" />

                            <EditText
                                android:id="@ id/gspET_Intermediary_Bank_Address"
                                android:layout_width="fill_parent"
                                android:layout_height="80dp"
                                android:layout_marginTop="5dp"
                                android:background="@drawable/button_shape"
                                android:inputType="textMultiLine"
                                android:paddingLeft="5dp"
                                android:paddingTop="5dp"
                                android:textColor="#241444"
                                android:textSize="19sp" />


                        </LinearLayout>
                    </ScrollView>
                </LinearLayout>

                <LinearLayout
                    android:id="@ id/lastrowLayout"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_marginTop="7dp"
                    android:baselineAligned="false"
                    android:orientation="horizontal"
                    android:padding="10dp" >

                    <CheckBox
                        android:id="@ id/android"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.50"
                        android:text="@string/I_Accept_Terms_Conditions"
                        android:textColor="@android:color/black" />

                    <ImageView
                        android:id="@ id/buttonSubmit_Next"
                        android:layout_width="0dp"
                        android:layout_height="70dp"
                        android:layout_weight="0.40"
                        android:contentDescription="@string/desc"
                        android:src="@drawable/next_btton" />
                </LinearLayout>
            </RelativeLayout>
        </RelativeLayout>

    </RelativeLayout>
 

Снимок экрана 2014-06-24 в 4.05.30 вечера

Комментарии:

1. поместите снимок экрана планшета, чтобы я мог найти, в чем проблема

2. @Mahesh, выше у меня есть снимок экрана.

3. @Robotics: u r тестирование в эмуляторе, тестирование на реальном устройстве

4. @Kaushik: нет тестирования только в эмуляторе.

5. @Robotics: ты меня не понял, я сказал тебе не тестировать в эмуляторе. Протестируйте в реальном 10-inch tablet , если он у вас есть, и следуйте шаблону проектирования, который покажет вам Vinakay.

Ответ №1:

 <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            >

            // your left side part

        </LinearLayout>

         <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            >
            // your right side part

        </LinearLayout>


    </LinearLayout>
 

а также использовать разные изображения для 10-дюймовых планшетов

Ответ №2:

  • Не масштабируйте изображения с помощью layout_width или layout_height самостоятельно. Я вижу, что в указанных ImageView вами dp значениях это заставит систему масштабировать ваше изображение, что может привести к размытию. Вместо этого используйте ресурсы, зависящие от размера и плотности, внутри папок, которые можно рисовать, например
 res/drawable-mdpi/icon.png   //for medium-density screens
res/drawable-hdpi/icon.png   //for high-density screens
 
  • Вы можете создать конкретный макет, соответствующий размеру экрана, и разложить его по reslayout-xxx папкам
  • Везде, где это возможно, используйте изображения с 9 патчами
  • Если у вас есть только одно изображение и его нужно масштабировать для другого экрана, тогда используйте изображение с наивысшим разрешением и сохраните его в папке drawable-nodpi, укажите либо высоту, либо ширину и позвольте системе выбрать другое, чтобы изображение было правильно масштабировано.

Читайте : http://developer.android.com/guide/practices/screens_support.html#screen-independence

Масштабирование изображения: http://argillander.wordpress.com/2011/11/24/scale-image-into-imageview-then-resize-imageview-to-match-the-image/

Комментарии:

1. да, винаяк прав, вы не должны масштабировать изображения с помощью dp