Swipe back and forth between a number of DialogFragments
I've been trying to write code which will allow me to swipe back and forth between 3 DialogFragment views which overlay the main Activity.
To be more specific, each view should be swipeable from left to right and vice versa across the entire UI, in much the same way as fragments are in a ViewPager (with limits set at the bounds like so | 1 <--> 2 <--> 3 |) . Like fragments in ViewPager, each DialogFragment should come to rest in a natural position at the centre of the screen after swiping, and the transition animation should be similar.
Ideally, the layout and functionality would be similar to the respective defaults of a DialogFragment overlaying an activity.
Initially, I attempted this with a ViewPager but ran into trouble as the fragments didn't display with the intended layout. The main problem I had here was that the ViewPager stretched the layout of the DialogFragment across the entire UI. Furthermore, the only option I found for resizing the layout of the fragment was to limit the boundaries of the ViewPager, but of course this meant that the transitions occurred in an area smaller than the UI rather than across the entire UI. Mike's provided a brief explanation why this happens in the comments below.
I've also attempted a different approach of creating a child DialogFragment within blank ViewPager fragments. However, so far I've been unsuccessful as the ViewPager functionalilty isn't operational while the child DialogFragment is visible.
In the case of a 'work around' solution things that I want to mimic from the DialogFragment view include:
- The shadowed / darkened background outside of the DialogFragment view.
- The ability to tap outside of DialogFragment view to close the DialogFragment view (and by extension the ViewPager) and return to the main activity.
android android-viewpager android-animation android-dialogfragment
|
show 17 more comments
I've been trying to write code which will allow me to swipe back and forth between 3 DialogFragment views which overlay the main Activity.
To be more specific, each view should be swipeable from left to right and vice versa across the entire UI, in much the same way as fragments are in a ViewPager (with limits set at the bounds like so | 1 <--> 2 <--> 3 |) . Like fragments in ViewPager, each DialogFragment should come to rest in a natural position at the centre of the screen after swiping, and the transition animation should be similar.
Ideally, the layout and functionality would be similar to the respective defaults of a DialogFragment overlaying an activity.
Initially, I attempted this with a ViewPager but ran into trouble as the fragments didn't display with the intended layout. The main problem I had here was that the ViewPager stretched the layout of the DialogFragment across the entire UI. Furthermore, the only option I found for resizing the layout of the fragment was to limit the boundaries of the ViewPager, but of course this meant that the transitions occurred in an area smaller than the UI rather than across the entire UI. Mike's provided a brief explanation why this happens in the comments below.
I've also attempted a different approach of creating a child DialogFragment within blank ViewPager fragments. However, so far I've been unsuccessful as the ViewPager functionalilty isn't operational while the child DialogFragment is visible.
In the case of a 'work around' solution things that I want to mimic from the DialogFragment view include:
- The shadowed / darkened background outside of the DialogFragment view.
- The ability to tap outside of DialogFragment view to close the DialogFragment view (and by extension the ViewPager) and return to the main activity.
android android-viewpager android-animation android-dialogfragment
1
ViewPager
won't work withDialogFragment
s.ViewPager
works by manipulating childView
s attached directly to it. In aDialogFragment
, theView
is in aDialog
, in a completely separate window.
– Mike M.
Nov 24 '18 at 6:10
1
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
1
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
1
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
1
Oh, yeah, no, it's just that particulargetSystemService()
overload that's 23+. You can usewinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove theLayoutInflater
. It was left over from earlier testing.
– Mike M.
Nov 28 '18 at 10:32
|
show 17 more comments
I've been trying to write code which will allow me to swipe back and forth between 3 DialogFragment views which overlay the main Activity.
To be more specific, each view should be swipeable from left to right and vice versa across the entire UI, in much the same way as fragments are in a ViewPager (with limits set at the bounds like so | 1 <--> 2 <--> 3 |) . Like fragments in ViewPager, each DialogFragment should come to rest in a natural position at the centre of the screen after swiping, and the transition animation should be similar.
Ideally, the layout and functionality would be similar to the respective defaults of a DialogFragment overlaying an activity.
Initially, I attempted this with a ViewPager but ran into trouble as the fragments didn't display with the intended layout. The main problem I had here was that the ViewPager stretched the layout of the DialogFragment across the entire UI. Furthermore, the only option I found for resizing the layout of the fragment was to limit the boundaries of the ViewPager, but of course this meant that the transitions occurred in an area smaller than the UI rather than across the entire UI. Mike's provided a brief explanation why this happens in the comments below.
I've also attempted a different approach of creating a child DialogFragment within blank ViewPager fragments. However, so far I've been unsuccessful as the ViewPager functionalilty isn't operational while the child DialogFragment is visible.
In the case of a 'work around' solution things that I want to mimic from the DialogFragment view include:
- The shadowed / darkened background outside of the DialogFragment view.
- The ability to tap outside of DialogFragment view to close the DialogFragment view (and by extension the ViewPager) and return to the main activity.
android android-viewpager android-animation android-dialogfragment
I've been trying to write code which will allow me to swipe back and forth between 3 DialogFragment views which overlay the main Activity.
To be more specific, each view should be swipeable from left to right and vice versa across the entire UI, in much the same way as fragments are in a ViewPager (with limits set at the bounds like so | 1 <--> 2 <--> 3 |) . Like fragments in ViewPager, each DialogFragment should come to rest in a natural position at the centre of the screen after swiping, and the transition animation should be similar.
Ideally, the layout and functionality would be similar to the respective defaults of a DialogFragment overlaying an activity.
Initially, I attempted this with a ViewPager but ran into trouble as the fragments didn't display with the intended layout. The main problem I had here was that the ViewPager stretched the layout of the DialogFragment across the entire UI. Furthermore, the only option I found for resizing the layout of the fragment was to limit the boundaries of the ViewPager, but of course this meant that the transitions occurred in an area smaller than the UI rather than across the entire UI. Mike's provided a brief explanation why this happens in the comments below.
I've also attempted a different approach of creating a child DialogFragment within blank ViewPager fragments. However, so far I've been unsuccessful as the ViewPager functionalilty isn't operational while the child DialogFragment is visible.
In the case of a 'work around' solution things that I want to mimic from the DialogFragment view include:
- The shadowed / darkened background outside of the DialogFragment view.
- The ability to tap outside of DialogFragment view to close the DialogFragment view (and by extension the ViewPager) and return to the main activity.
android android-viewpager android-animation android-dialogfragment
android android-viewpager android-animation android-dialogfragment
edited Nov 24 '18 at 8:35
Josh Hardman
asked Nov 24 '18 at 6:03
Josh HardmanJosh Hardman
345315
345315
1
ViewPager
won't work withDialogFragment
s.ViewPager
works by manipulating childView
s attached directly to it. In aDialogFragment
, theView
is in aDialog
, in a completely separate window.
– Mike M.
Nov 24 '18 at 6:10
1
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
1
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
1
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
1
Oh, yeah, no, it's just that particulargetSystemService()
overload that's 23+. You can usewinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove theLayoutInflater
. It was left over from earlier testing.
– Mike M.
Nov 28 '18 at 10:32
|
show 17 more comments
1
ViewPager
won't work withDialogFragment
s.ViewPager
works by manipulating childView
s attached directly to it. In aDialogFragment
, theView
is in aDialog
, in a completely separate window.
– Mike M.
Nov 24 '18 at 6:10
1
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
1
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
1
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
1
Oh, yeah, no, it's just that particulargetSystemService()
overload that's 23+. You can usewinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove theLayoutInflater
. It was left over from earlier testing.
– Mike M.
Nov 28 '18 at 10:32
1
1
ViewPager
won't work with DialogFragment
s. ViewPager
works by manipulating child View
s attached directly to it. In a DialogFragment
, the View
is in a Dialog
, in a completely separate window.– Mike M.
Nov 24 '18 at 6:10
ViewPager
won't work with DialogFragment
s. ViewPager
works by manipulating child View
s attached directly to it. In a DialogFragment
, the View
is in a Dialog
, in a completely separate window.– Mike M.
Nov 24 '18 at 6:10
1
1
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
1
1
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
1
1
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
1
1
Oh, yeah, no, it's just that particular
getSystemService()
overload that's 23+. You can use winManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove the LayoutInflater
. It was left over from earlier testing.– Mike M.
Nov 28 '18 at 10:32
Oh, yeah, no, it's just that particular
getSystemService()
overload that's 23+. You can use winManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove the LayoutInflater
. It was left over from earlier testing.– Mike M.
Nov 28 '18 at 10:32
|
show 17 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455598%2fswipe-back-and-forth-between-a-number-of-dialogfragments%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455598%2fswipe-back-and-forth-between-a-number-of-dialogfragments%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
ViewPager
won't work withDialogFragment
s.ViewPager
works by manipulating childView
s attached directly to it. In aDialogFragment
, theView
is in aDialog
, in a completely separate window.– Mike M.
Nov 24 '18 at 6:10
1
I've got a much better implementation now. Don't use that shaky code I linked you before. I'll get you an example here in a little while. Hope you didn't spend too much time on that.
– Mike M.
Nov 26 '18 at 5:45
1
Hey, sorry, your comments got lost in my flooded inbox. I don't really know of any particular resources to recommend, other than the official documentation and samples, and here, of course. I just picked it up from various places as I went. I'm not one for any kind of structured learning, these days. Anyhoo, I'm putting the finishing touches on my new example right now. Hopefully have it ready in about an hour.
– Mike M.
Nov 26 '18 at 8:41
1
OK, give this a whirl: drive.google.com/file/d/1aea7tZ9mt9wUxHg_O8QkdVl2jGON7KYh/…. I'm pretty happy with it. Gimme a shout if you have any issues getting it working.
– Mike M.
Nov 26 '18 at 10:35
1
Oh, yeah, no, it's just that particular
getSystemService()
overload that's 23+. You can usewinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
instead. And just remove theLayoutInflater
. It was left over from earlier testing.– Mike M.
Nov 28 '18 at 10:32