2016-11-08 9 views
2

現在、私はlistを含むandroidアプリケーションを開発中です。 私はモバイル(ハンドセット)デバイスで1つ作成しました。 と私はそれをresponsiveの錠剤(7 "-10")ディスプレイにしたいと思っています。 headercolumnはモバイルディスプレイと同じように見えます。ここTableLayout Responsiveを作成するには

は5" 〜defferenceですと7" 表示:

5" display

Tablet Dispaly

これは私の現在のXMLコード

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" android:layout_height="match_parent" 
android:tag="reqtag" 
> 
<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:showDividers="beginning|end" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Date" 
      android:id="@+id/tvClaimDateReimbursementRequest" 

      android:layout_marginRight="50dp" 
      android:textSize="12dp" 
      android:width="100dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Type" 
      android:textSize="12dp" 
      android:layout_marginLeft="50dp" 
      android:layout_marginRight="50dp" 
      android:id="@+id/tvTypeRequestReimbursement" 
      android:width="80dp" /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Amount" 
      android:textSize="10dp" 
      android:layout_marginLeft="50dp" 
      android:layout_marginRight="50dp" 
      android:width="100dp" 
      android:id="@+id/tvAmountReimbursementRequest" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Status" 
      android:textSize="12dp" 
      android:layout_marginLeft="50dp" 
      android:layout_marginRight="50dp" 
      android:id="@+id/tvStatusReimbursementRequest" /> 
    </TableRow> 
</TableLayout> 

である私がしましたここに書類を見てくださいhttps://developer.android.com/guide/practices/screens_support.html

しかし、私はまだそれを取得しません、 このようなことを行うためのベストプラクティスはありますか?

おかげ

+0

変更テーブル:線形レイアウト(縦)と下:私は(縦)と内部の親linenarのレイアウトを追加しますこの線形レイアウトは、リサイクル・ビューです。それを反応させるには、Stas Melnychenkoが言ったように重力を使う。マージンを取り除き、より大きいテキストサイズを与え、テキストを追加するためにstrings.xmlを使用します。テキストをハーベストしないでください。コードを維持する必要がある場合は有用ではありません。 – Jaco

答えて

2

TableRowLinearLayoutあるので、あなたは、すべてのヘッダTextViewため

android:layout_width="0dp" 
android:layout_weight="1" 

設定してみてください。

しかし、私はTableViewが最良のアプローチではないと信じています。あなたが何を達成したいと考えているかを記述すれば、より良い方法を見つけ出すことができます。

0

tablerowレイアウトにweightsum ..を割り当て、すべてのテキストビューにその重みを均等に割り当てます。以下のように:

<TableRow 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:weight_sum="1" > 

<TextView 
      android:layout_width="0dp" 
      android:layout_weight=".2" // for five texts .2 for each 
      android:layout_height="wrap_content" 
      ...... /> 
0

あなたのテーブルの行 に水平に子を配置レイアウトをこのコードを試してみてください。 TableLayoutの子として常に使用する必要があります。 TableRowの親がTableLayoutでない場合、TableRowは水平のLinearLayoutとして動作します。

TableRowの子は、XMLファイルのlayout_widthおよびlayout_height属性を指定する必要はありません。 TableRowは常にこれらの値をそれぞれMATCH_PARENTとWRAP_CONTENTに強制します。

関連する問題