Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No scrolling effect with ScrollView in PopupWindow

Tags:

android

I want to implement a popup menu with complex effects, one of them is to support scrolling. It seems PopupMenu and AlertDialog can not meet the requirement what I need. So I tried PopupWindow with ScrollView.

Firstly, I prepared a layout which has a simple strcture just like what ApiDemo shows:

ScrollView
    LinearLayout with Vertical attribute
       TextView
       TextView  
       TextView  
       ...  

Secondarily, I new a PopupWindow with this layout and 200width/300height, show it at somewhere with showAtLocation().

I can make scrollbar displayed and has scroll effect, but TextViews in LinearLayout do NOT scroll(they are in fixed position)!

Something is wrong but I have no sense on it. (android3.0)

Thanks for any warm-heart man who can give me some tips.

-_-!!

like image 982
Archy Avatar asked Jan 05 '12 13:01

Archy


1 Answers

I also faced similar issue. Some how wrapping relative layout in scrollview is not working for popupwindow.

I tried wrapping individual views under scrollview and it worked for me. PLease have a look below. Hope this helps

 <RelativeLayout   xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#eebd9c"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
   <ScrollView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/textView2" >

    <TextView
        android:id="@+id/textView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:ems="15"
        android:gravity="fill_horizontal"
        android:minLines="6"
        android:scrollbars="vertical"
        android:singleLine="false"
        android:text="Multiline text"
        android:textAppearance="?android:attr/textAppearanceSmall" />
    </ScrollView></RelativeLayout>
like image 112
Avinash Agrawal Avatar answered Sep 30 '22 16:09

Avinash Agrawal