ListView和TextView滚动问题
在我的应用程序包含顶部的ListView和底部的TextView。我想自动在TextView中滚动文本。但它不滚动,我还提交了以下ListView和TextView滚动问题
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true" />
</LinearLayout>
感谢布局XML代码的解决方案
集属性android:scrollingCache="true"
在你的ListView
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollingCache="true"
android:layout_weight="1" />
当ListView被关注时TextView的内容不滚动。可能吗 ? – Riskhan 2012-01-31 10:29:58
你想在文本视图中进行水平滚动吗? 然后你需要把你的文本视图放在一个'HorizontalScrollView'里面:http://developer.android.com/reference/android/widget/HorizontalScrollView.html – 2012-01-31 11:05:33
如果它解决了你的问题,请把它标记为答案。它会帮助其他人识别解决方案。 – 2012-02-01 18:08:10
解决滚动问题,是里面添加horizontalScrollview文本视图。
而且,当您将下面的textview添加到ListView时,如果listView高度超过设备高度,您将无法使用textView,因此我建议您将LinearLayout的父视图和RelativeLayout父视图制作为LinearLayout和HorizontalScrollView。将LinearLayouts参数设置为width-> fill-Parent和layout-height = fill-parent,然后将textView和HorizontalLayout的参数设置为width = fill-parent和height = wrap-content,并将bottom和parent对齐。
更新的一些代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_above="@+id/scrollView" />
</LinearLayout>
<HorizontalScrollView android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_align_parent_bottom="true">
<TextView
android:layout_width="wrap_conetent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:singleLine="true"
/>
</HorizontalScrollView>
</RelativeLayout>
拖动滚动视图,使滚动视图 – 2012-01-31 06:12:43
我如何能做到这里面新的布局? – Riskhan 2012-01-31 07:11:56