0

我正在使用数据来构建ViewGroup. 是,除了ViewGroup叶子LinearLayouts,它们是TextViews。因为 Data 绘制了层次结构,所以我以编程方式动态LinearLayoutsTextViews从单个 XML 文件中扩展和。

我的问题:LinearLayout当我使用属性 创建 a ,然后将 a或 otherwrap_content膨胀到其中时,我无法让父母(或足够多的父母)重绘,尊重新视图。这些似乎总是以 0 大小出现,因为当它们第一次被创建时(在它们的孩子被充气之前),它们什么都没有。TextViewLinearLayoutLinearLayouts

我试过调用一些常用的方法,ViewGroup但似乎没有任何效果。

4

1 回答 1

0

我之前没有登录。请在下面找到:顶部父 XML、子布局 XML、textView XML 和插入代码。谢谢你的协助!

顶级父 Xml <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tasks_view"> </LinearLayout>

子布局 XML <LinearLayout android:orientation="vertical" android:id="@+id/task_line_tasks" android:layout_width="fill_parent" android:layout_height="wrap_content"/>

文本视图 XML <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:textSize="10pt" android:layout_width="40dip" android:layout_height="fill_parent" android:background="#EAADEA" android:textColor="#000000"/>

插入代码:
inflater.inflate(R.layout.person_line, tasks_view); newPersonLine = (LinearLayout) tasks_view.getChildAt(tasks_view.getChildCount()-1); newPersonLine.setId(i); newPersonName = (TextView)newPersonLine.getChildAt(0); newPersonName.setId(0); newPersonName.setText(people[i][0]);

于 2010-08-29T15:05:12.963 回答