Reputation: 4470
In my app contains a ListView on top and a TextView on bottom. I want to scroll text in the TextView automatically. But it is not scrolling, i also submitted layout xml code below
<?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>
thanks for a solution
Upvotes: 0
Views: 3395
Reputation: 7024
set attribute android:scrollingCache="true"
in your ListView
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollingCache="true"
android:layout_weight="1" />
Upvotes: 1
Reputation: 29199
Solution to scrolling issue, is add text view inside horizontalScrollview.
And as you are adding textview below to ListView, you wont be able to textView, if listView height exceeds device height, so I would suggest you to make LinearLayout parent of ListView and a RelativeLayout parent to the LinearLayout and HorizontalScrollView. Let LinearLayouts Params to width->fill-Parent and layout-height=fill-parent, and above textView, and HorizontalLayout's Params to width=fill-parent, and height= wrap-content, and align bottom to parent.
Update by Some Code:
<?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>
Upvotes: 1