Проблема с отображением стрелки влево и вправо при горизонтальной прокрутке?

У меня есть один вид горизонтальной прокрутки, в котором есть изображения, если прокрутка пользователя и дополнительные изображения доступны, чем мне нужно отобразить правую стрелку вправо, чтобы указать пользователю, чтобы прокрутить его снова и увидеть другие изображения.

Заранее спасибо.


person Anand    schedule 21.02.2011    source источник
comment
Привет, Ананд, сошлитесь на мой ответ в моем вопросе друга stackoverflow.com/questions/3845625/   -  person Sankar Ganesh PMP    schedule 21.02.2011


Ответы (1)


Я только что столкнулся с этой проблемой и понял, что для этой цели вы можете использовать функцию затухания прокрутки. Просто используйте относительную компоновку, в которой у вас есть 3 представления: стрелка влево, стрелка вправо, горизонтальная прокрутка. Установите для fadingEdgeLength достаточную длину, чтобы при исчезновении прокрутки отображалась стрелка.

Пример:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ImageView android:src="@drawable/arrow_l" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true" />

    <ImageView android:src="@drawable/arrow_r" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true" />         

    <HorizontalScrollView android:id="@+id/horizontalScroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:scrollbars="none" 
        android:fadingEdgeLength="20dp">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/harokLayout"
            android:background="#EEEEEE"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" />

        </LinearLayout>

    </HorizontalScrollView>

</RelativeLayout>
person peter.bartos    schedule 29.06.2011
comment
Это android:fadingEdgeLength=20dp, ниже прокрутки изображение стрелки появляется в затемненной области. - person peter.bartos; 24.11.2015
comment
Похоже, это не работает на телефонах 5.+ или, по крайней мере, на Nexus 6, который у меня есть. - person JPM; 01.12.2015