2

i have some views within a scrollview in a xml file.i want to change the title of the action bar while scrolling up.anyaone please help me how to do that..

this is my xml file

<ScrollView 
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="name"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="email"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="address"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>
    </ScrollView>
ananya
  • 1,001
  • 6
  • 33
  • 50

1 Answers1

1

You want to observe the scrollview's scrolling? For whatever reason you can't do this via the Android SDK for scrollviews (you can for listviews however). As a result there are whole libraries!

https://github.com/ksoichiro/Android-ObservableScrollView

Or you can easily implement something similar fairly simpply such as https://stackoverflow.com/a/3952629/3865761 if it meets your needs. Standing on the shoulders of stack overflow giant's as it were.

Once you can detect the scrolling, simply have methods such as onScrollUp() that increases the font size for your textviews, and resetTextViewState() which sets it back to its default called from the onScrollingChanged() callback you implement.

Community
  • 1
  • 1
Ashton Engberg
  • 5,949
  • 2
  • 19
  • 14
  • but i don't have a list view.i am designing this xml file only for a my profile page.and i want on scrolling up ,name of the person should appear in action bar.so can i use this lib https://github.com/ksoichiro/Android-ObservableScrollView – ananya Mar 16 '15 at 11:12
  • but i don't have a list view.i am designing this xml file only for a my profile page.and i want on scrolling up ,name of the person should appear in action bar – ananya Mar 16 '15 at 11:12
  • You are free to use the lib, just check the license. Although the lib might be overkill, if you check the stack overflow link I posted, it contains some sample code for setting up a simple callback that will tell you when and how the scroll view is being scrolled. At which point, depending on the arguments passed, you can hide/show the person in the actionbar. – Ashton Engberg Mar 18 '15 at 18:37
  • how can i design a activity in androd like truecaller application's (version 5.22) my profile page . – ananya Mar 23 '15 at 05:51
  • You have to implement the effects you want by listening to the callback that triggers when scrolling happen. Ie, if you wanted to change the size of the title text in the action bar, you would first set up the 'onScrolled' callback from your scrollview to the Activity, then compute the size of the text based on the scroll amount or position, then change the size of the textview. Or you can find a library to do this for you, something like https://android-arsenal.com/details/1/1577 – Ashton Engberg Mar 23 '15 at 17:19
  • thanks for ur response.bt one thing.i am using eclipse .so can i use this lib or i have to use android studio. – ananya Mar 24 '15 at 05:06
  • You can import it into Eclipse, mark it as a library project then import it into your app. But you should update to Android Studio. – Ashton Engberg Mar 24 '15 at 06:12
  • thanks.ok How do I add a library (android-support-v7-appcompat) to android studio.actually i ceated a sample application using android studio. i am new to android studio.en eclipse we have a option in file->proporties there we can add a lib to a project.bt in android studio hw can we add a lib to a project.and i want to add (android-support-v7-appcompat) .hw can i do that.plz tell me step by step – ananya Mar 24 '15 at 06:19
  • Simple google search will give you a lot of step by step instructions, you can see one such stack overflow post here: http://stackoverflow.com/questions/16580586/add-support-library-to-android-studio-project – Ashton Engberg Mar 24 '15 at 17:11