开发者

Horizontal Scroll view left right arrow display problem?

I have one horizontal scroll view in that there are images if user scroll and further images are available than I need to display right side right arrow to indicate us开发者_运维百科er to scroll it again and see other images.

Thanks in advance.


I've just came across this problem and I realized, that you can use scrollview fade function for this purpose. Simply use relative layout in which you have 3 view: leftarrow, rightarrow, horizontalscroll. Set fadingEdgeLength to sufficient length, so when the scrollview fades out, arrow will appear.

Example:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜