Проблема с прокруткой ListView и TextView - PullRequest
0 голосов
/ 31 января 2012

В моем приложении сверху есть ListView и снизу TextView.Я хочу прокрутить текст в TextView автоматически.Но это не прокрутка, я также представил макет кода XML ниже

<?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>

enter image description here

спасибо за решение

Ответы [ 2 ]

1 голос
/ 31 января 2012

установить атрибут 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" /> 
1 голос
/ 31 января 2012

Решение проблемы с прокруткой, это добавить текстовое представление в horizontalScrollview.

И так как вы добавляете текстовое представление ниже в ListView, вы не сможете использовать textView, если listView height превышает высоту устройства, поэтому я бы предложил вамсделать LinearLayout родительским для ListView и RelativeLayout родительским для LinearLayout и HorizontalScrollView.Позвольте LinearLayouts Params to width-> fill-Parent и layout-height = fill-parent и над textView, а Parameters HorizontalLayout в width = fill-parent и height = wrap-content, и выровняйте нижнюю часть по отношению к родителю.

Обновление некоторым кодом:

<?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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...