2012-02-27 16 views
1

私は初心者のAndroidプログラマで、バージョンごとにアプリに加えられた変更の表を表示するアクティビティを作成するように割り当てられています。この表には、Id、Type、Description、およびVersionの4つの列があります。TableRowの列は、スペーシング要素ではない重みと重みを使用して分割されました。

これを行うために、私はscrollViewにTableLayoutを配置しました。次に、私はTableRows用のテンプレートを用意しています。これはランタイム時に動的に拡張されます。列の幅は静的に保つ必要があります。高さはオーバーフローするが、幅はオーバーフローする可能性があります。

これを達成するために、私は体重を使用してみました。それぞれ、列と行のコンテナの合計プロパティです:& (私はlayout_widthを両方ともゼロに設定しています)。

問題は、列が画面境界の外に広がっていることです。私は画像を掲載するが、私は権限を持っていない。

(風景が近くに見えますが、外側の境界線がまだ切り取られていることがわかります)。

子供の体重が合計の約45%になると、体重が右に近づくことに気付きました。

最後に、列を区切るビューにはゼロの重みと1dipの幅が与えられています。 (私はそれが問題を引き起こす可能性があるかどうかはわかりません)。

アドバイスはありますか?

私には、それが横長モードのように幅を使用しているように見えます。私は肖像画と風景の2つのレイアウトを作らなければならないのですか?

Iは、テーブルの行のXMLレイアウトを追加しました:

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

    <LinearLayout 
     android:id="@+id/table_row_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <View 
      android:id="@+id/top_border" 
      android:layout_width="match_parent" 
      android:layout_height="1dip" 
      android:background="#FFFFFF" /> 

     <LinearLayout 
      android:id="@+id/horizontal_container" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="4" > 

      <View 
       android:id="@+id/view1" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_id" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Id" android:textSize="10sp" android:layout_weight="0.5"/> 

      <View 
       android:id="@+id/view2" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_type" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Type" android:textSize="10sp" android:layout_weight="1"/> 

      <View 
       android:id="@+id/view3" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_desc" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Description" android:textSize="10sp" android:layout_weight="2"/> 

      <View 
       android:id="@+id/view4" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_version" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Version" android:textSize="10sp" android:layout_weight="0.5"/> 

      <View 
       android:id="@+id/view6" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 
     </LinearLayout> 

     <View 
      android:id="@+id/view7" 
      android:layout_width="match_parent" 
      android:layout_height="1dip" android:background="#FFFFFF"/> 

    </LinearLayout> 

</TableRow> 

上下ビューが上部と下部の境界線です。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:scrollbarAlwaysDrawVerticalTrack="true"> 

    <ScrollView 
     android:id="@+id/view_scroll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" android:fillViewport="true"> 

     <TableLayout 
      android:id="@+id/table_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:shrinkColumns="0" 
      android:stretchColumns="0" > 
     </TableLayout> 

    </ScrollView> 

</LinearLayout> 
+1

あなたが参考のためにあなたの行レイアウトを追加できますか?また、個々のウェイトの合計が実際に['android:weightSum'](http://developer.android.com/reference/android/widget/LinearLayout)で指定された値を超えないかどうかを再度確認します。 html#attr_android:weightSum)(私はあなたがこの属性を参照するときにタイプミスをしたと仮定しています)。 –

答えて

1

おかげMH:

そして、ここでは、そのあまりにも追加取得テーブルのレイアウトです。

ご連絡が遅くて申し訳ありません。 (私はAndroidとStack Overflowの新機能です...あなたが私の質問に答えたことを気づかなかったのです)私は行レイアウトを追加しました。

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

    <LinearLayout 
     android:id="@+id/table_row_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <View 
      android:id="@+id/top_border" 
      android:layout_width="match_parent" 
      android:layout_height="1dip" 
      android:background="#FFFFFF" /> 

     <LinearLayout 
      android:id="@+id/horizontal_container" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="4" > 

      <View 
       android:id="@+id/view1" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_id" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Id" android:textSize="10sp"  android:layout_weight="0.20"/> 

      <View 
       android:id="@+id/view2" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_type" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Type" android:textSize="10sp" android:layout_weight="0.5"/> 

      <View 
       android:id="@+id/view3" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_desc" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Description" android:textSize="10sp" android:layout_weight="1"/> 

      <View 
       android:id="@+id/view4" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 

      <TextView 
       android:id="@+id/txt_version" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="Version" android:textSize="10sp" android:layout_weight="0.25"/> 

      <View 
       android:id="@+id/view6" 
       android:layout_width="1dip" 
       android:layout_height="match_parent" 
       android:background="#FFFFFF" android:layout_weight="0.01"/> 
     </LinearLayout> 

     <View 
      android:id="@+id/view7" 
      android:layout_width="match_parent" 
      android:layout_height="1dip" android:background="#FFFFFF"/> 

    </LinearLayout> 

</TableRow> 

デビッド

関連する問題