Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ViewPager and setClipChildren(false)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thesalan  
View profile  
 More options Aug 27 2012, 4:29 am
From: Thesalan <thesa...@gmail.com>
Date: Mon, 27 Aug 2012 01:29:20 -0700 (PDT)
Local: Mon, Aug 27 2012 4:29 am
Subject: ViewPager and setClipChildren(false)

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

The result looks like this :

<https://lh4.googleusercontent.com/-DjFOnG7O0wY/UDstWN3AE2I/AAAAAAAAAf...>
The ViewPager here is just on "Item4", and with setClipChildren(false) we
can see the other item.

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 :

<https://lh3.googleusercontent.com/-clS7voj3rLk/UDsvfP1HnhI/AAAAAAAAAf...>

When sliding :

<https://lh5.googleusercontent.com/-3tYaKu_Oz7w/UDsvnljXJ0I/AAAAAAAAAf...>

Anybody else already encounter this problem? I think is an optimization on
these devices, but how can I bypass this?

Thanks in advance!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Aug 28 2012, 7:44 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 28 Aug 2012 07:41:31 -0400
Local: Tues, Aug 28 2012 7:41 am
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

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.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thesalan  
View profile  
 More options Aug 28 2012, 8:54 am
From: Thesalan <thesa...@gmail.com>
Date: Tue, 28 Aug 2012 05:54:24 -0700 (PDT)
Local: Tues, Aug 28 2012 8:54 am
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

Thanks a lot!!

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)

Le mardi 28 août 2012 13:44:28 UTC+2, Mark Murphy (a Commons Guy) a écrit :

  TestViewPager.zip
486K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Aug 28 2012, 9:33 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 28 Aug 2012 09:30:38 -0400
Local: Tues, Aug 28 2012 9:30 am
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

I'll try to take a look at this later today.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Aug 28 2012, 5:09 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 28 Aug 2012 17:05:37 -0400
Local: Tues, Aug 28 2012 5:05 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

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.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 28 2012, 5:14 pm
From: Romain Guy <romain...@android.com>
Date: Tue, 28 Aug 2012 23:10:47 +0200
Local: Tues, Aug 28 2012 5:10 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)
Sounds like a bug, please file a report with an apk or a sample
project that reproduces the issue and I'll fix it.

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 28 2012, 5:14 pm
From: Romain Guy <romain...@android.com>
Date: Tue, 28 Aug 2012 23:11:02 +0200
Local: Tues, Aug 28 2012 5:11 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)
To file a bug report, go to http://b.android.com btw

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Aug 28 2012, 5:26 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 28 Aug 2012 17:24:10 -0400
Local: Tues, Aug 28 2012 5:24 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

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.

Posted as http://code.google.com/p/android/issues/detail?id=36788

Thanks!

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thesalan  
View profile  
 More options Aug 28 2012, 5:55 pm
From: Thesalan <thesa...@gmail.com>
Date: Tue, 28 Aug 2012 14:55:22 -0700 (PDT)
Local: Tues, Aug 28 2012 5:55 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

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.

I tried to force software mode just on the ViewPager with
setLayerType(View.LAYER_TYPE_SOFTWARE, null) (see here :
http://developer.android.com/guide/topics/graphics/hardware-accel.html) but
it doesn't work : content stay inside the viewpager.

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 :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kostya Vasilyev  
View profile  
 More options Aug 28 2012, 6:05 pm
From: Kostya Vasilyev <kmans...@gmail.com>
Date: Wed, 29 Aug 2012 02:02:26 +0400
Local: Tues, Aug 28 2012 6:02 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

2012/8/29 Thesalan <thesa...@gmail.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.

> I tried to force software mode just on the ViewPager with
> setLayerType(View.LAYER_TYPE_SOFTWARE, null) (see here :
> http://developer.android.com/guide/topics/graphics/hardware-accel.html)
> but it doesn't work : content stay inside the viewpager.

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thesalan  
View profile  
 More options Aug 28 2012, 6:18 pm
From: Thesalan <thesa...@gmail.com>
Date: Tue, 28 Aug 2012 15:18:18 -0700 (PDT)
Local: Tues, Aug 28 2012 6:18 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

Ok, thank you for the precision!

Le mercredi 29 août 2012 00:05:24 UTC+2, Kostya Vasilyev a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 28 2012, 6:21 pm
From: Romain Guy <romain...@android.com>
Date: Wed, 29 Aug 2012 00:18:53 +0200
Local: Tues, Aug 28 2012 6:18 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)
Kostya, you are wrong :)

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.)

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy (Google)  
View profile  
 More options Aug 28 2012, 6:23 pm
From: "Romain Guy (Google)" <romain...@android.com>
Date: Tue, 28 Aug 2012 15:23:03 -0700 (PDT)
Local: Tues, Aug 28 2012 6:23 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

Thesalan, it's incorrect. setLayeType(View.LAYER_TYPE_SOFTWARE, null)
always works, no matter how or if hardware acceleration is enabled.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thesalan  
View profile  
 More options Aug 28 2012, 6:28 pm
From: Thesalan <thesa...@gmail.com>
Date: Tue, 28 Aug 2012 15:28:41 -0700 (PDT)
Local: Tues, Aug 28 2012 6:28 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

Ok thanks! But when I do it on the ViewPager, the clipping stay... I will
try again tomorrow, it's late for me here ;)

Thanks again!

Le mercredi 29 août 2012 00:23:03 UTC+2, Romain Guy (Google) a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kostya Vasilyev  
View profile  
 More options Aug 28 2012, 6:32 pm
From: Kostya Vasilyev <kmans...@gmail.com>
Date: Wed, 29 Aug 2012 02:29:49 +0400
Local: Tues, Aug 28 2012 6:29 pm
Subject: Re: [android-developers] ViewPager and setClipChildren(false)

Thanks for clarifying, I stand corrected.

-- K

2012/8/29 Romain Guy <romain...@android.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Smith  
View profile  
 More options Aug 28 2012, 7:45 pm
From: Dave Smith <dasmith1...@gmail.com>
Date: Tue, 28 Aug 2012 16:45:11 -0700 (PDT)
Local: Tues, Aug 28 2012 7:45 pm
Subject: Re: ViewPager and setClipChildren(false)

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:

    private void init() {
        setClipChildren(false);
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thesalan  
View profile  
 More options Aug 29 2012, 3:31 am
From: Thesalan <thesa...@gmail.com>
Date: Wed, 29 Aug 2012 00:31:13 -0700 (PDT)
Local: Wed, Aug 29 2012 3:31 am
Subject: Re: ViewPager and setClipChildren(false)

Exactly! Thanks Dave!

Le mercredi 29 août 2012 01:45:11 UTC+2, Dave Smith a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 29 2012, 5:24 am
From: Romain Guy <romain...@android.com>
Date: Wed, 29 Aug 2012 02:21:30 -0700
Local: Wed, Aug 29 2012 5:21 am
Subject: Re: [android-developers] Re: ViewPager and setClipChildren(false)

Note that using software layers comes at a performance and memory cost.

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Smith  
View profile  
 More options Aug 29 2012, 10:49 am
From: Dave Smith <dasmith1...@gmail.com>
Date: Wed, 29 Aug 2012 07:49:22 -0700 (PDT)
Local: Wed, Aug 29 2012 10:49 am
Subject: Re: [android-developers] Re: ViewPager and setClipChildren(false)

Which is why we will all be eagerly watching the bug that Mark filed in
anticipation :)

Cheers,
Dave Smith
@devunwired


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »