Search code examples
androidtextviewhorizontalscrollview

Custom HorizontalSctollView with TextView in Android


I have some category like shown in fig-1.I have used HorizontalScrollViewfor category scrolling but when scroll scrolling progress display in the bottom of the textview(Give in picture).Actually don't want to show this and also want to put two button for left and right scroll(shown in fig-2).I have searched lot but haven't done this, if you have any idea please suggest me.fig-1 enter image description here

enter image description here

fig-2


Solution

  • Put this property in HorizontalScrollView

    android:scrollbars="none" in your xml file for disable scrollbar as picture 1.
    
    <HorizontalScrollView android:id="@+id/horizontalScroll"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" 
         android:scrollbars="none" >
    

    Try Following xml for Solution of Picture 2.

    <?xml version="1.0" encoding="UTF-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" >
    
        <ImageView android:src="@drawable/ic_launcher" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_alignParentLeft="true"/>
    
        <ImageView android:src="@drawable/ic_launcher" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_alignParentRight="true"/>         
    
        <HorizontalScrollView android:id="@+id/horizontalScroll"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:scrollbars="none" 
            android:fadingEdgeLength="20dp">
    </HorizontalScrollView>
    </RelativeLayout>
    

    Check this link .