简体   繁体   English

如何在Android中仅以人像模式设计10英寸平板电脑?

[英]How to design in 10 inch tablet only in portrait mode in Android?

在此处输入图片说明 I have to design an application for 10 inch tab in Android.But when i run the application the design is in blur or not clear .I don't know why. 我必须在Android中为10英寸标签设计应用程序。但是当我运行该应用程序时,设计模糊或不清楚。我不知道为什么。 I have also declare the android:screenOrientation="portrait" in manifest .How to design properly and where I'm doing wrong in xml file .Thanks in advance. 我也在清单xml file中声明了android:screenOrientation="portrait" 。如何正确设计以及xml file中我做错的地方。谢谢。

Here is my xml file code 这是我的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>

Screen Shot 2014-06-24 at 4.05.30 PM 屏幕截图2014年6月24日下午4.05.30

  • Do not scale the images using layout_width or layout_height by your self. 请勿自行使用layout_widthlayout_height缩放图像。 I can see in the ImageView you have specified dp values, this will make system to scale your image which may cause blur. 我可以在ImageView看到您已指定dp值,这将使系统缩放图像,这可能会导致模糊。 Instead use size and density-specific resources inside drawable folders like 而是在可绘制文件夹中使用特定于大小和密度的资源,例如
 res/drawable-mdpi/icon.png //for medium-density screens res/drawable-hdpi/icon.png //for high-density screens 
  • You can create specific layout suitable to the screen size and palce it in res\\layout-xxx folders 您可以创建适合屏幕大小的特定布局,并将其放在res\\layout-xxx文件夹中

  • Wherever possible use 9-patch images 尽可能使用9补丁图像

  • If you have only one image and have to be scaled for different screen then use highest resolution image and keep it in drawable-nodpi folder and specify either height or width and lets system decide other so that image get scaled properly. 如果只有一幅图像并且必须针对不同的屏幕缩放,则使用最高分辨率的图像并将其保存在drawable-nodpi文件夹中,并指定高度或宽度,然后让系统决定其他图像,以便正确缩放图像。

Read : http://developer.android.com/guide/practices/screens_support.html#screen-independence 阅读: http : //developer.android.com/guide/practices/screens_support.html#screen-independence

Image scaling: http://argillander.wordpress.com/2011/11/24/scale-image-into-imageview-then-resize-imageview-to-match-the-image/ 图像缩放: http : //argillander.wordpress.com/2011/11/24/scale-image-into-imageview-then-resize-imageview-to-match-the-image/

<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>

and also use different images for 10 inch tablets 并为10英寸平板电脑使用不同的图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM