2016-04-01 12 views
0

に指定されたスペースを占有していない私は、2つのXMLファイルを持っている私のアダプタで、私のcompliance_details.xmlコードですTextviewsは画面

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

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_marginLeft="10dp" 
       android:layout_marginTop="15dp"> 

       <TextView 
        android:id="@+id/taskNameLabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_column="1" 
        android:layout_marginRight="70dp" 
        android:layout_weight="3" 
        android:singleLine="true" 
        android:text="TaskName" 
        android:textColor="#000" 
        android:textSize="20sp" /> 

       <TextView 
        android:id="@+id/dueDateLabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_column="1" 
        android:layout_marginRight="20dp" 
        android:layout_weight="1" 
        android:singleLine="true" 
        android:text="Due Date" 
        android:textColor="#000" 
        android:textSize="20sp" /> 

       <TextView 
        android:id="@+id/ageingLabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_column="1" 
        android:layout_marginRight="20dp" 
        android:layout_weight="1" 
        android:singleLine="true" 
        android:text="Ageiging" 
        android:textColor="#000" 
        android:textSize="20sp" /> 

      </TableRow> 

     </TableLayout> 

     <ListView 
      android:id="@+id/listView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:paddingTop="10dp" /> 

    </LinearLayout> 


and following is my compliance_details_row.xml code 

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


    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="15dp"> 

      <TextView 
       android:id="@+id/taskNameValue" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="1" 
       android:layout_marginRight="70dp" 
       android:layout_weight="3" 
       android:singleLine="true" 
       android:text="TaskName" 
       android:textColor="#000" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/dueDateValue" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="1" 
       android:layout_marginRight="20dp" 
       android:layout_weight="1" 
       android:singleLine="true" 
       android:text="Due Date" 
       android:textColor="#000" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/ageingValue" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="1" 
       android:layout_marginRight="20dp" 
       android:layout_weight="1" 
       android:singleLine="true" 
       android:text="Ageiging" 
       android:textColor="#000" 
       android:textSize="20sp" /> 

     </TableRow> 

    </TableLayout> 

</LinearLayout> 

、イムの膨張後compliance_details.xmlcompliance_details_row.xml

と呼ばれますcompliance_row.xmlを伴うcompliance_details_row.xml

しかし、私がそうするとき、compliance_details_rowの要素は少し歪んでいます。 enter image description here

あなたは上の写真から見ることができたとして、コンプライアンス名がタイトルTaskNameの下に来るべきであるが、コンプライアンス名が少し歪んでいるとも期日値は一部のみ表示されます。どのようにこれを整理することができますか?

答えて

1

これを達成するためにTableLayoutは本当に必要ありません。 weightSumのLinearLayoutを使用してください。希望の比率を取得するには、各TextViewの重み値を変更します。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:weightSum="3"> 

     <TextView 
      android:id="@+id/taskNameValue" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:singleLine="true" 
      android:text="TaskName" 
      android:textColor="#000" 
      android:textSize="20sp" /> 

     <TextView 
      android:id="@+id/dueDateValue" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:singleLine="true" 
      android:text="Due Date" 
      android:textColor="#000" 
      android:textSize="20sp" /> 

     <TextView 
      android:id="@+id/ageingValue" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:singleLine="true" 
      android:text="Ageiging" 
      android:textColor="#000" 
      android:textSize="20sp" /> 

</LinearLayout> 
1

あなたの親ビュー(compliance_details_row.xml)から...タスク名、duedateとaginを削除し、カスタムアダプタの最初の要素として追加します。 compliance_row.xmlは、このレイアウト内の行がTable形式であることを確認するだけで、親レイアウトのビューを制御することはできません。したがって、compliance_details_row.xmlcompliance_row.xmlをでLinearLayoutに変更するか、compliance_details_row.xmlから3つの要素を削除してください。

1

XMLの両方のためにandroid:layout_weightプロパティでのLinearLayout使用してみてください:

compliance_details.xml

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/taskNameLabel" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.50" 
     android:text="TaskName" 
     android:layout_marginRight="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/dueDateLabel" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_weight="0.25" 
     android:text="Due Date" 
     android:layout_marginRight="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/ageingLabel" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_marginRight="5dp" 
     android:layout_weight="0.25" 
     android:text="Ageiging" 
     android:textColor="#000" 
     android:textSize="20sp" /> 
</LinearLayout> 


<ListView 
    android:id="@+id/listView" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:paddingTop="10dp" /> 

compliance_details_row.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TextView 
     android:id="@+id/taskNameValue" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="5dp" 
     android:layout_weight="0.50" 
     android:singleLine="true" 
     android:text="TaskName" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/dueDateValue" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_marginRight="5dp" 
     android:layout_weight="0.25" 
     android:singleLine="true" 
     android:text="Due Date" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/ageingValue" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="5dp" 
     android:layout_weight="0.25" 
     android:singleLine="true" 
     android:text="Ageiging" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

</LinearLayout>