2015-10-09 107 views
0

我已經爲平板電腦創建了一個Android應用程序,該應用程序有15列大表。該應用程序工作正常,平板電腦表似乎沒問題。問題是,當我在智能手機中打開應用程序時,表格分辨率正在打破。平板電腦Android應用程序分辨率正在突破智能手機

我似乎有很多應用程序在智能手機和平板電腦中都能正常工作。 我是新來的android編程,任何人都可以請告訴我一些解決方案如何實現解決方案問題。我需要爲智能手機和平板電腦

enter image description here

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

你可以發佈一些截圖和一些XML代碼? – pgiitu

+0

@pgiitu我已經發布了一個示例代碼 –

+0

檢查[這裏](http://developer.android.com/guide/practices/screens_support.html#support) – pRaNaY

回答

1

您可以隨時使用「價值」的文件夾設置尺寸和相應的佈局不同屏幕尺寸的設備。 您也可以使用不同屏幕尺寸的'佈局'文件夾並相應地創建您的佈局。

以獲取更多信息,您可以使用佈局文件夾這樣,

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

如果我做什麼如果我有一個大表 –

+0

對於一個大表,使用ScrollView或兩個(假設這是你想讓用戶能夠在他們的手機上做的)。 –

+0

如果多窗格平板電腦佈局需要至少600dp的屏幕寬度,則應將其放置在/ layout-sw600dp中。像這樣,你知道屏幕尺寸的dp(密度像素),你可以把你的佈局放在該文件夾中。 –

1

我會建議使用在Android上CardView。 您可以擁有自定義適配器並可以顯示數據。

相關問題