We are very close to production with our app, but are having some really strange and annoying performance issues when using the PopupWindow in Android. As soon as it is open, scrolling simply slooooows down and is extremely jerky. If I turn off hardware acceleration in the manifest, the problem almost disappears - unfortunately everything else in the app renders slowly in software mode so that is not an option. I posted this on stackoverflow as well, but doesn't seem to get a response, so I'm hoping to get a more specified audience here ;-).
I have tried to turn off hardware accelleration on the popup container (layout) and also on the scrollview but it doesn't seem to be doing any difference: Do I need to specifically turn off hardware accelleration on all child-views as well to have any effect?
I have also tried to turn off transparency but it makes no difference neither.
The code for initiating the popupwindow is here:
fillMatchPopupWindow() is the function that fills the popupwindow with data.
The layoutfile is structured like this:
You guys have any ideas what I'm doing wrong or how I can disable hardware accelleration for the popupwindow but not for anything else. Also, when openeing and closing the popupwindow we run an animation - and this runs smooth as silk, so the jerky behavious is only visible when scrolling in the popupwindow. Also, I have other popupwindow which is coded in the same architecture, and those also struggle with jerky motion.
BR Michael
I have tried to turn off hardware accelleration on the popup container (layout) and also on the scrollview but it doesn't seem to be doing any difference: Do I need to specifically turn off hardware accelleration on all child-views as well to have any effect?
I have also tried to turn off transparency but it makes no difference neither.
The code for initiating the popupwindow is here:
Code:
final LayoutInflater inflater = (LayoutInflater) Fragment_matches.this.getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.layout_matches_popup,
(ViewGroup) getActivity().findViewById(R.id.layoutmatchespopup));
fillMatchPopupWindow(context, match, layout, inflater);
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int fifthHeight = size.y/5;
int height = size.y-fifthHeight;
if(pwindo != null) //TODO SIZECALC
{
pwindo.dismiss();
if(matchPopupTimer != null)
matchPopupTimer.cancel();
}
pwindo = new PopupWindow(layout, width-20, height, true);
pwindo.setAnimationStyle(R.style.AnimationPopup);
pwindo.setBackgroundDrawable(new BitmapDrawable());
pwindo.showAtLocation(layout, Gravity.TOP, 0, 140);
ImageButton btnClose = (ImageButton) layout.findViewById(R.id.popup_close);
btnClose.bringToFront();
btnClose.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(pwindo != null)
pwindo.dismiss();
}
});
fillMatchPopupWindow() is the function that fills the popupwindow with data.
The layoutfile is structured like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutmatchespopup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/popupshape"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:paddingBottom="15dp"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/popup_favteammatch_header"
style="@style/FontHeadlineCaps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/popup_favteammatch_header" >
</TextView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginTop="2dp"
>
<ImageButton android:id="@+id/popup_close"
android:contentDescription="Close"
android:layout_height="32dp"
android:layout_width="32dp"
android:src="@drawable/popup_close_red"
android:scaleType="centerInside"
style="?android:attr/borderlessButtonStyle"
android:layout_margin="0px"
android:padding="0px"
></ImageButton>
</LinearLayout>
</LinearLayout>
.......
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/detailsscrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollX="0px"
android:scrollY="0px"
android:paddingLeft="5dp"
android:paddingRight="5dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/statistics"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
.......
<RelativeLayout
android:id="@+id/panelpreviousmatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/roundedsquare"
android:alpha="0.8"
android:paddingTop="6dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginBottom="15dp" >
<ListView
android:id="@+id/id_list_viewprevmatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingTop="4dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
You guys have any ideas what I'm doing wrong or how I can disable hardware accelleration for the popupwindow but not for anything else. Also, when openeing and closing the popupwindow we run an animation - and this runs smooth as silk, so the jerky behavious is only visible when scrolling in the popupwindow. Also, I have other popupwindow which is coded in the same architecture, and those also struggle with jerky motion.
BR Michael