I started Android development last week, and I have a problem with a code on some devices :
I have to develop an application with a specific controller like a horizontal wheel. To do this, I want to use the ViewPager, with setClipChildren(false) to extend the view. I based on the following code : https://gist.github.com/8cbe094bb7a783e37ad1
This works greats on emulator (tested on API 7 to 16) and some devices!
But I encounter some problems on more recent devices, like HTC One X (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager doesn't really extended! Just the current item is shown, and when you are sliding, the next item is shown :
On Mon, Aug 27, 2012 at 4:29 AM, Thesalan <thesa...@gmail.com> wrote:
> Hi!
> I started Android development last week, and I have a problem with a code
> on some devices :
> I have to develop an application with a specific controller like a
> horizontal wheel. To do this, I want to use the ViewPager, with
> setClipChildren(false) to extend the view. I based on the following code :
> https://gist.github.com/8cbe094bb7a783e37ad1
> This works greats on emulator (tested on API 7 to 16) and some devices!
> But I encounter some problems on more recent devices, like HTC One X
> (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager
> doesn't really extended! Just the current item is shown, and when you are
> sliding, the next item is shown :
> Anybody else already encounter this problem? I think is an optimization on
> these devices, but how can I bypass this?
> Thanks in advance!
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
I repeat : this works greats on emulator and older devices, but not on my HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10 (Android 4.1.1)
Le mardi 28 août 2012 13:44:28 UTC+2, Mark Murphy (a Commons Guy) a écrit :
> That's rather strange, particularly considering that ViewPager is part of > the Android Support package, not the firmware.
> If you can create a complete sample project that demonstrates this, upload > the source somewhere, as I'd like to take a look at it.
> On Mon, Aug 27, 2012 at 4:29 AM, Thesalan <thes...@gmail.com <javascript:>
> > wrote:
>> Hi!
>> I started Android development last week, and I have a problem with a code >> on some devices :
>> I have to develop an application with a specific controller like a >> horizontal wheel. To do this, I want to use the ViewPager, with >> setClipChildren(false) to extend the view. I based on the following code : >> https://gist.github.com/8cbe094bb7a783e37ad1
>> This works greats on emulator (tested on API 7 to 16) and some devices!
>> But I encounter some problems on more recent devices, like HTC One X >> (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager >> doesn't really extended! Just the current item is shown, and when you are >> sliding, the next item is shown :
>> Anybody else already encounter this problem? I think is an optimization >> on these devices, but how can I bypass this?
>> Thanks in advance!
>> -- >> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscribe@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
> I repeat : this works greats on emulator and older devices, but not on my
> HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10
> (Android 4.1.1)
> Le mardi 28 août 2012 13:44:28 UTC+2, Mark Murphy (a Commons Guy) a écrit :
>> That's rather strange, particularly considering that ViewPager is part of
>> the Android Support package, not the firmware.
>> If you can create a complete sample project that demonstrates this,
>> upload the source somewhere, as I'd like to take a look at it.
>> On Mon, Aug 27, 2012 at 4:29 AM, Thesalan <thes...@gmail.com> wrote:
>>> Hi!
>>> I started Android development last week, and I have a problem with a
>>> code on some devices :
>>> This works greats on emulator (tested on API 7 to 16) and some devices!
>>> But I encounter some problems on more recent devices, like HTC One X
>>> (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager
>>> doesn't really extended! Just the current item is shown, and when you are
>>> sliding, the next item is shown :
>>> Anybody else already encounter this problem? I think is an optimization
>>> on these devices, but how can I bypass this?
>>> Thanks in advance!
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-d...@**googlegroups.com
>> _The Busy Coder's Guide to Android Development_ Version 4.1 Available!
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
On Tue, Aug 28, 2012 at 8:54 AM, Thesalan <thesa...@gmail.com> wrote:
> The project is attached to this post, at this lighter version (like we can
> found here https://gist.github.com/8cbe094bb7a783e37ad1)
> I repeat : this works greats on emulator and older devices, but not on my
> HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10
> (Android 4.1.1)
I can reproduce your problem.
It appears to be tied to hardware acceleration, insofar as if I add
android:hardwareAccelerated="false" to the activity, things work on
hardware where it failed before (and also fails if I set the value
explicity to "true").
Since the issues of clipping and hardware acceleration are beyond my
area of expertise, I can't explain why this is the case. Rather than
disable hardware acceleration for the whole activity, you could
experiment with disabling it just for the ViewPager itself. And, of
course, if we're lucky, somebody who understands more about this area
will chime in and explain where things are going wrong.
On Tue, Aug 28, 2012 at 11:05 PM, Mark Murphy <mmur...@commonsware.com> wrote:
> On Tue, Aug 28, 2012 at 8:54 AM, Thesalan <thesa...@gmail.com> wrote:
>> The project is attached to this post, at this lighter version (like we can
>> found here https://gist.github.com/8cbe094bb7a783e37ad1)
>> I repeat : this works greats on emulator and older devices, but not on my
>> HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10
>> (Android 4.1.1)
> I can reproduce your problem.
> It appears to be tied to hardware acceleration, insofar as if I add
> android:hardwareAccelerated="false" to the activity, things work on
> hardware where it failed before (and also fails if I set the value
> explicity to "true").
> Since the issues of clipping and hardware acceleration are beyond my
> area of expertise, I can't explain why this is the case. Rather than
> disable hardware acceleration for the whole activity, you could
> experiment with disabling it just for the ViewPager itself. And, of
> course, if we're lucky, somebody who understands more about this area
> will chime in and explain where things are going wrong.
> _The Busy Coder's Guide to Android Development_ Version 4.1 Available!
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
-- Romain Guy
Android framework engineer
romain...@android.com
On Tue, Aug 28, 2012 at 11:10 PM, Romain Guy <romain...@android.com> wrote:
> Sounds like a bug, please file a report with an apk or a sample
> project that reproduces the issue and I'll fix it.
> On Tue, Aug 28, 2012 at 11:05 PM, Mark Murphy <mmur...@commonsware.com> wrote:
>> On Tue, Aug 28, 2012 at 8:54 AM, Thesalan <thesa...@gmail.com> wrote:
>>> The project is attached to this post, at this lighter version (like we can
>>> found here https://gist.github.com/8cbe094bb7a783e37ad1)
>>> I repeat : this works greats on emulator and older devices, but not on my
>>> HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10
>>> (Android 4.1.1)
>> I can reproduce your problem.
>> It appears to be tied to hardware acceleration, insofar as if I add
>> android:hardwareAccelerated="false" to the activity, things work on
>> hardware where it failed before (and also fails if I set the value
>> explicity to "true").
>> Since the issues of clipping and hardware acceleration are beyond my
>> area of expertise, I can't explain why this is the case. Rather than
>> disable hardware acceleration for the whole activity, you could
>> experiment with disabling it just for the ViewPager itself. And, of
>> course, if we're lucky, somebody who understands more about this area
>> will chime in and explain where things are going wrong.
>> _The Busy Coder's Guide to Android Development_ Version 4.1 Available!
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscribe@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
On Tue, Aug 28, 2012 at 5:10 PM, Romain Guy <romain...@android.com> wrote:
> Sounds like a bug, please file a report with an apk or a sample
> project that reproduces the issue and I'll fix it.
Mark, a huge thank you!! I never thought the problem would come from hardware acceleration (I'm a beginner after all ^_^). Indeed, my current rom force hardware acceleration for all applications.
But by specifying it in the manifest as you say it works very well! And given the application, it does not pose any problems to do without hardware acceleration.
Again, thank you very much Mark!
Le mardi 28 août 2012 23:09:38 UTC+2, Mark Murphy (a Commons Guy) a écrit :
> On Tue, Aug 28, 2012 at 8:54 AM, Thesalan <thes...@gmail.com <javascript:>> > wrote: > > The project is attached to this post, at this lighter version (like we > can > > found here https://gist.github.com/8cbe094bb7a783e37ad1)
> > I repeat : this works greats on emulator and older devices, but not on > my > > HTC One X with last OTA (Android 4.0.4) and Nexus S with CyanogenMod 10 > > (Android 4.1.1)
> I can reproduce your problem.
> It appears to be tied to hardware acceleration, insofar as if I add > android:hardwareAccelerated="false" to the activity, things work on > hardware where it failed before (and also fails if I set the value > explicity to "true").
> Since the issues of clipping and hardware acceleration are beyond my > area of expertise, I can't explain why this is the case. Rather than > disable hardware acceleration for the whole activity, you could > experiment with disabling it just for the ViewPager itself. And, of > course, if we're lucky, somebody who understands more about this area > will chime in and explain where things are going wrong.
> Mark, a huge thank you!! I never thought the problem would come from
> hardware acceleration (I'm a beginner after all ^_^). Indeed, my current
> rom force hardware acceleration for all applications.
You can't force hardware accel off with setLayertType if it's already been
set to enabled elsewhere (in the manifest, or I suppose in your ROM). Going
the other way (software -> GPU) is possible.
>> Mark, a huge thank you!! I never thought the problem would come from >> hardware acceleration (I'm a beginner after all ^_^). Indeed, my current >> rom force hardware acceleration for all applications.
> You can't force hardware accel off with setLayertType if it's already been > set to enabled elsewhere (in the manifest, or I suppose in your ROM). Going > the other way (software -> GPU) is possible.
setLayerType() always lets you go back to software. It doesn't let you
go to hardware if the app is not hardware accelerated. The whole point
of setLayerType(SOFTWARE) is to be able to selectively disable
hardware acceleration for small parts of the app (to work around
missing features or compatibility issues.)
>> Mark, a huge thank you!! I never thought the problem would come from
>> hardware acceleration (I'm a beginner after all ^_^). Indeed, my current rom
>> force hardware acceleration for all applications.
> You can't force hardware accel off with setLayertType if it's already been
> set to enabled elsewhere (in the manifest, or I suppose in your ROM). Going
> the other way (software -> GPU) is possible.
> -- K
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
-- Romain Guy
Android framework engineer
romain...@android.com
>>> Mark, a huge thank you!! I never thought the problem would come from >>> hardware acceleration (I'm a beginner after all ^_^). Indeed, my current >>> rom force hardware acceleration for all applications.
>> You can't force hardware accel off with setLayertType if it's already >> been set to enabled elsewhere (in the manifest, or I suppose in your ROM). >> Going the other way (software -> GPU) is possible.
>>>> Mark, a huge thank you!! I never thought the problem would come from >>>> hardware acceleration (I'm a beginner after all ^_^). Indeed, my current >>>> rom force hardware acceleration for all applications.
>>> You can't force hardware accel off with setLayertType if it's already >>> been set to enabled elsewhere (in the manifest, or I suppose in your ROM). >>> Going the other way (software -> GPU) is possible.
> setLayerType() always lets you go back to software. It doesn't let you
> go to hardware if the app is not hardware accelerated. The whole point
> of setLayerType(SOFTWARE) is to be able to selectively disable
> hardware acceleration for small parts of the app (to work around
> missing features or compatibility issues.)
Calling setLayerType() on just the View will work, but you have to do it on the correct view. In this case, the issue that doesn't work with hardware acceleration is the parent ViewGroup clipping its children, so the PagerContainer in the example is the view that you need to call it on, not the ViewPager itself. If you modify PagerContainer.java in the gist like so:
You should be able to enable hardware acceleration in your manifest and the pager code will still work as expected. I will update the gist example when I have a spare moment with some discussion, and I have starred the issue Mark created (you should do the same).
On Monday, August 27, 2012 2:29:20 AM UTC-6, Thesalan wrote:
> Hi!
> I started Android development last week, and I have a problem with a code > on some devices :
> I have to develop an application with a specific controller like a > horizontal wheel. To do this, I want to use the ViewPager, with > setClipChildren(false) to extend the view. I based on the following code : > https://gist.github.com/8cbe094bb7a783e37ad1
> This works greats on emulator (tested on API 7 to 16) and some devices!
> But I encounter some problems on more recent devices, like HTC One X > (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager > doesn't really extended! Just the current item is shown, and when you are > sliding, the next item is shown :
> Calling setLayerType() on just the View will work, but you have to do it > on the correct view. In this case, the issue that doesn't work with > hardware acceleration is the parent ViewGroup clipping its children, so the > PagerContainer in the example is the view that you need to call it on, not > the ViewPager itself. If you modify PagerContainer.java in the gist like > so:
> You should be able to enable hardware acceleration in your manifest and > the pager code will still work as expected. I will update the gist example > when I have a spare moment with some discussion, and I have starred the > issue Mark created (you should do the same).
> Cheers,
> Dave Smith
> @devunwired
> On Monday, August 27, 2012 2:29:20 AM UTC-6, Thesalan wrote:
>> Hi!
>> I started Android development last week, and I have a problem with a code >> on some devices :
>> I have to develop an application with a specific controller like a >> horizontal wheel. To do this, I want to use the ViewPager, with >> setClipChildren(false) to extend the view. I based on the following code : >> https://gist.github.com/8cbe094bb7a783e37ad1
>> This works greats on emulator (tested on API 7 to 16) and some devices!
>> But I encounter some problems on more recent devices, like HTC One X >> (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager >> doesn't really extended! Just the current item is shown, and when you are >> sliding, the next item is shown :
On Tue, Aug 28, 2012 at 4:45 PM, Dave Smith <dasmith1...@gmail.com> wrote:
> Thesalan -
> Calling setLayerType() on just the View will work, but you have to do it
> on the correct view. In this case, the issue that doesn't work with
> hardware acceleration is the parent ViewGroup clipping its children, so the
> PagerContainer in the example is the view that you need to call it on, not
> the ViewPager itself. If you modify PagerContainer.java in the gist like
> so:
> You should be able to enable hardware acceleration in your manifest and
> the pager code will still work as expected. I will update the gist example
> when I have a spare moment with some discussion, and I have starred the
> issue Mark created (you should do the same).
> Cheers,
> Dave Smith
> @devunwired
> On Monday, August 27, 2012 2:29:20 AM UTC-6, Thesalan wrote:
>> Hi!
>> I started Android development last week, and I have a problem with a code
>> on some devices :
>> This works greats on emulator (tested on API 7 to 16) and some devices!
>> But I encounter some problems on more recent devices, like HTC One X
>> (Android 4.0.4) and a Nexus S (CM10 - Android 4.1.1) : the ViewPager
>> doesn't really extended! Just the current item is shown, and when you are
>> sliding, the next item is shown :
>> Anybody else already encounter this problem? I think is an optimization
>> on these devices, but how can I bypass this?
>> Thanks in advance!
>> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
-- Romain Guy
Android framework engineer
romain...@android.com
On Wednesday, August 29, 2012 3:24:50 AM UTC-6, Romain Guy (Google) wrote:
> Note that using software layers comes at a performance and memory cost.
> On Tue, Aug 28, 2012 at 4:45 PM, Dave Smith <dasmi...@gmail.com<javascript:> > > wrote:
>> Thesalan -
>> Calling setLayerType() on just the View will work, but you have to do it >> on the correct view. In this case, the issue that doesn't work with >> hardware acceleration is the parent ViewGroup clipping its children, so the >> PagerContainer in the example is the view that you need to call it on, not >> the ViewPager itself. If you modify PagerContainer.java in the gist like >> so:
>> You should be able to enable hardware acceleration in your manifest and >> the pager code will still work as expected. I will update the gist example >> when I have a spare moment with some discussion, and I have starred the >> issue Mark created (you should do the same).