简体   繁体   中英

Tablet Android application resolution is breaking in smartphone

I have created an android application for tablet, the application is having big table with 15 columns. The application is working fine and the table seems okay in tablet. The issue is that when I open the application in smart phone the table resolution is breaking.

I have seems many application which works fine in both smartphone and tablet. I am new to android programming, Can anyone please tell me some solution how to achieve the resolution issue. Do I need to create separate application for smartphone and tablet

在此处输入图片说明

xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/oil" >

  <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_margin="10dp"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_marginRight="10dip"
            android:orientation="horizontal" >

            <EditText
                android:id="@+id/EditText03"
                style="@style/EditTextStyleWhite"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_marginEnd="5dp"
                android:layout_weight="50"
                android:cursorVisible="true"
                android:ems="10"
                android:hint="@string/password"
                android:inputType="textPassword"
                android:paddingEnd="10dp"
                android:paddingStart="10dp"
                android:textSize="14sp" />

            <EditText
                android:id="@+id/EditText02"
                style="@style/EditTextStyleWhite"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_weight="50"
                android:cursorVisible="true"
                android:ems="10"
                android:hint="@string/password"
                android:inputType="textPassword"
                android:paddingEnd="10dp"
                android:paddingStart="10dp"
                android:textSize="14sp" >

                <requestFocus />
            </EditText>

            <EditText
                android:id="@+id/EditText01"
                style="@style/EditTextStyleWhite"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_weight="50"
                android:cursorVisible="true"
                android:ems="10"
                android:hint="@string/password"
                android:inputType="textPassword"
                android:paddingEnd="10dp"
                android:paddingStart="10dp"
                android:textSize="14sp" />

            <EditText
                android:id="@+id/password"
                style="@style/EditTextStyleWhite"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_weight="50"
                android:cursorVisible="true"
                android:ems="10"
                android:hint="@string/password"
                android:inputType="textPassword"
                android:paddingEnd="10dp"
                android:paddingStart="10dp"
                android:textSize="14sp" />

            <EditText
                android:id="@+id/password6"
                style="@style/EditTextStyleWhite"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_weight="50"
                android:cursorVisible="true"
                android:ems="10"
                android:hint="@string/password"
                android:inputType="textPassword"
                android:paddingEnd="10dp"
                android:paddingStart="10dp"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:orientation="horizontal"
            android:paddingTop="5dp" >
        </LinearLayout>

        <TableLayout
            android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:background="@android:color/black" >

            <TableRow>

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:layout_height="30dp"
                    android:background="@android:color/white"
                    android:gravity="center"
                    android:text="Person Names"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Employee No"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Description"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Result in Entra"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Current Status"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Image Upload"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Remark"
                    android:textColor="@android:color/black" />

                <TextView
                    android:layout_margin="1dp"
                    android:layout_weight="1"
                    android:background="@android:color/white"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="Actions"
                    android:textColor="@android:color/black" />
            </TableRow>
        </TableLayout>


    </LinearLayout>

</LinearLayout>

You can always use the 'values' folder to set the dimensions and accordingly to the layout for different screen size devices. And you can also use the 'layout' folder with different screen sizes and create your layout accordingly.

for more information you can use layout folders like this,

 res/layout/my_layout.xml             // layout for normal screen size ("default")
 res/layout-small/my_layout.xml       // layout for small screen size
 res/layout-large/my_layout.xml       // layout for large screen size
 res/layout-xlarge/my_layout.xml      // layout for extra large screen size
 res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

I would recommend using a CardView in Android. You can have your custom adapter and can display the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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