我有两个名为的xml文件compliance_details.xml
,compliance_details_row.xml
以下是我的Compliance_details.xml代码
<?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_row.xml扩展了Compliance_details_row.xml。
但是当我这样做时,compliance_details_row的元素会有些失真。
从上图可以看到,合规名称应该在标题下,TaskName
但是合规名称有些失真,而且到期日期值也只部分可见。我怎样才能解决这个问题?
您实际上不需要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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句