android-viewpager

Swipe Direction in ViewPager

久未见 提交于 2019-12-18 04:34:18
问题 I have an Android app that uses ViewPager and FragmentStatePagerAdapter. I however need to add a new feature in which I have to know the swipe direction to move from one fragment view to another, left or right. (i.e, when I swipe left, I would do one thing, and when I swipe right I would do something else). Please note, I do not need the events to happen AFTER the swipe is over. I have to do those events as the swipe occurs. I thought of using setOnPageChangeListener() but it does not tell me

How can i create ViewPager with previous and next page preview, and centred one zoomed from preview

吃可爱长大的小学妹 提交于 2019-12-18 04:28:08
问题 viewPager.setClipToPadding(false); viewPagerMusicCategory.setPadding(width/3, 0, width /3, 0); viewPagerMusicCategory.setPageMargin(40)); I got next and previous preview by above code. But now i need that zoom effect for centred page. Thanks in advance 回答1: viewPagerMusicCategory.setPageTransformer(false, new ViewPager.PageTransformer() { @Override public void transformPage(View page, float position) { Log.e("pos",new Gson().toJson(position)); if (position < -1) { page.setScaleY(0.7f); page

FragmentStatePagerAdapter onPageSelected event

时光怂恿深爱的人放手 提交于 2019-12-18 03:43:24
问题 I have a FragmentStatePagerAdapter with 6 fragments inside. Each Fragment connect's to the server and loads data. Right now, the server connection is being done in Fragment.onStart(), that means that at any moment, I have 3 http requests going (the selected Fragment, and one to each side). What I want is to have only one connection at the time, so I figure to use viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(final int position) {

ViewPager with expandable child

余生长醉 提交于 2019-12-18 02:58:12
问题 I'm trying to create collapsable calendar. I'm using custom calendarView in ViewPager, so when expand/collapse button pressed my calendarView animate collapsing all calendar weeks except only one. Goal is to swipe month when expanded (which works as i want) and swipe weeks when collapsed. Below calendarView is ListView with some events, when user collapse calendar - listView height must change. Problem is when i trying to collapse calendarView in ViewPager, he doesn't change height.

Getting the error “Java.lang.IllegalStateException Activity has been destroyed” when using tabs with ViewPager

大憨熊 提交于 2019-12-18 02:57:30
问题 I have an application that consists of using ActionBarSherlock in tab mode.I have 5 tabs and the content of each tab is handled using fragments. For tab2 though, I have a fragment the xml file of which holds a ViewPager element which in turn has some fragment pages. When I initially start the application the application, I am able to switch between tabs no problem but when I press on tab2 for the second time I get the error mentioned above. The main activity is as follows: public class

Android Parallax Effect and View Pager

无人久伴 提交于 2019-12-18 02:49:23
问题 I'm trying to achieve a parallax effect in my application. I have a FragmentActivity that implements the OnPageChangeListener interface and listens to my ViewPager scrolling events. To achieve this effect in my XML I have a LinearLayout behind all the other views with my background, and I move it in the onPageScrolled callback. If I simply swipe it's all ok, the effect works and the background position change. But when my finger leaves the screen, the background is redrawn at his original

ViewPager does not redraw content, remains/turns blank

我与影子孤独终老i 提交于 2019-12-17 23:44:13
问题 We're suffering from a very strange issue with ViewPager here. We embed lists on each ViewPager page, and trigger notifyDataSetChanged both on the list adapter and the view pager adapter when updating list data. What we observe is that sometimes, the page does not update its view tree, i.e. remains blank, or sometimes even disappears when paging to it. When paging back and forth a few times, the content will suddenly reappear. It seems as if Android is missing a view update here. I also

Nesting Android ViewPager, Swiping ListItems inside a ListView horizontally

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 23:13:27
问题 I have a ViewPager on the root-level of an activity. Each page of the pager contains a ListFragment (backed by a FragmentPagerAdapter). Some of the list view items should contain additionally ViewPagers to support swiping the content of those items (e. g. a horizontal gallery inside a list item). How can I nest view pagers? ViewPager -> ListView (in a page) -> ViewPager (inside a list item) I can swipe between the ListFragments horizontally and I can swipe the whole list vertically, but I

Control which directions the ViewPager can be scrolled, dynamically with UI feedback

眉间皱痕 提交于 2019-12-17 23:06:08
问题 I'm working on an app which uses many pages to swipe through, however at some pages I would like to be able to prevent scrolling to the next page until they've selected something. At the moment I've extended ViewPager: /* (non-Javadoc) * @see android.support.v4.view.ViewPager#onInterceptTouchEvent(android.view.MotionEvent) */ @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (this.canGoLeft || this.canGoRight) { return super.onInterceptTouchEvent(event); } return false; }

Dynamically set ViewPager height

做~自己de王妃 提交于 2019-12-17 22:48:58
问题 I am trying to put a ViewPager with different fragments with different heights. I know that wrap_content is not working with ViewPager so I am trying to set pager height dinamically. I am setting the pager height in a page listener: ... indicator.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int selected) { final View view = fragments[selected].getView(); if (view != null) { pager.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, view