2016-12-30 5 views
0

Simplifing私は2行のテーブルを持っています。 1つの行にTextViewがあり、もう1つの行に2つのtextViewがあります...私はandroid:layout_span = "2"を使用する必要がありますが、それはwowrkinではありません。私が持っている resutlこのXamarin Android TableRow android:layout_span = 2

enter image description here

そして、私のコードのようなものです私は一列にタイトルを必要とするこの

<?xml version="1.0" encoding="utf-8"?> 
 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="fill_parent" 
 
    android:orientation="vertical"> 
 
    <LinearLayout 
 
     android:layout_width="fill_parent" 
 
     android:layout_height="fill_parent" 
 
     android:orientation="vertical" > 
 
    <TableLayout 
 
      android:id="@+id/tableLayout1" 
 
      android:layout_width="fill_parent" 
 
      android:layout_height="wrap_content"> 
 
     <TableRow 
 
      android:gravity="center_horizontal" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content"> 
 
     <TextView 
 
       android:layout_span="2" 
 
       android:layout_width="300sp" 
 
       android:gravity="center" 
 
       android:textSize="11sp" 
 
       android:id="@+id/Orden" 
 
       android:textStyle="bold" 
 
       android:text="MY PORTATIL BATERIY 9V VRef>8,7V" /> 
 
     </TableRow> 
 
     <TableRow 
 
      android:gravity="center_horizontal" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content"> 
 
     <TextView 
 
      android:gravity="center" 
 
      android:textSize="10sp" 
 
      android:id="@+id/Orden" 
 
      android:text="V Med" /> 
 
     <TextView 
 
      android:gravity="center" 
 
      android:textSize="10sp" 
 
      android:id="@+id/Orden" 
 
      android:text="Venc Batery" /> 
 
     </TableRow> 
 
    
 

 
    </TableLayout> 
 
    </LinearLayout> 
 
    
 
</FrameLayout>

のようなものです。 私が紛失しているものは? ありがとうございますか?

答えて

0

あなたは親の全幅を使用するようにレイアウトを強制的にstretchColumns="*を使用することができます。

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 
    <TableLayout 
     android:id="@+id/tableLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:stretchColumns="*"> 
     <TableRow 
      android:gravity="center_horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <TextView 
        android:layout_span="2" 
        android:layout_width="300sp" 
        android:gravity="center" 
        android:textSize="11sp" 
        android:id="@+id/Orden" 
        android:textStyle="bold" 
        android:text="MY PORTATIL BATERIY 9V VRef>8,7V" /> 
     </TableRow> 
     <TableRow 
     android:gravity="center_horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:gravity="center" 
      android:textSize="10sp" 
      android:id="@+id/Orden" 
      android:text="V Med" /> 
     <TextView 
      android:gravity="center" 
      android:textSize="10sp" 
      android:id="@+id/Orden" 
      android:text="Venc Batery" /> 
     </TableRow> 
    </TableLayout> 
    </LinearLayout> 
</FrameLayout> 
+0

これは同じ結果です...それは3行で表示されます。それは、そのように2番目のtableRowの幅で幅のレイアウトを修正するようです。 – Diego

+1

@Diego私はあなたの 'TableLayout'定義を見逃してしまったので答えを更新しました – SushiHangover

0
解決

...

<TableLayout 
 
      android:id="@+id/tableLayout1" 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" 
 
      android:stretchColumns="*">

私は追加していません