大佬教程收集整理的这篇文章主要介绍了android – 以编程方式在(线性)布局(在ScrollView内)中添加视图,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
一种方法是使用ListView和自定义ArrayAdapter,但是,我必须将ListView放在ScrollView中,这是一个问题,即使我手动覆盖ListView的高度.它显示一个列表项,以及下一个列表项的一部分.
另一种方法是将LinearLayout定义为注释的持有者,而不是膨胀在其自己的xml文件中定义的另一个LinearLayouts,填充它的内容,附加到持有者的视图.从程序的角度来看,它工作得很好,除了它将评论推到新闻内容之下.就像,它在内容od news(内容重叠)下创建另一个可滚动的评论视图.
<LinearLayout> //global layout <LinearLayout> //views that hold title,date,content </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/commentsHolder" android:orientation="vertical"> <View android:layout_width="fill_parent" android:layout_height="2dp" android:BACkground="#ed1b24"/> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="KOMENTARI" android:layout_marginLeft="5dp"/> <View android:layout_width="fill_parent" android:layout_height="1dp" android:BACkground="#ed1b24"/> <LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:orientation="vertical" android:id="@+id/comments_holder_view" android:layout_weight="1"> </LinearLayout> </LinearLayout> </LinearLayout>
<LinearLayout xmlns:android="http://scheR_627_11845@as.android.com/apk/res/android" android:id="@+id/comments_holder_item" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="5dp"> <TextView android:id="@+id/comment_content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:BACkground="@drawable/comments_BACk_details" android:text="Ovde ide tekst komentara,koji se,naravno,dinamicki dodaje."/> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/comment_author" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/categoryStyle" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" | " style="@style/categoryStyle" /> <TextView android:id="@+id/comment_pubdate" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/categoryStyle"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="1dp" android:orientation="horizontal" android:layout_margin="5dp" android:BACkground="#d1d1d1"> </LinearLayout>
非常感谢您的回复.这对我来说非常重要.
以上是大佬教程为你收集整理的android – 以编程方式在(线性)布局(在ScrollView内)中添加视图全部内容,希望文章能够帮你解决android – 以编程方式在(线性)布局(在ScrollView内)中添加视图所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。