0

Does the android:clipChildren still works? I have a AbsoluteLayout with a size and set the clipChildren to false. When I add childeren that are bigger then the AbsoluteLayout the childeren are still clipped.

Anyone got this working?

Working with Android 2.2 (API level 8)


Update 20-01-11:

I can make something similiar with a RelativeLayout, but does the android:clipChildren work on that? btw, it's not needed that my application needs to work on any other platform then Android 2.2.

Peter Fortuin
  • 5,041
  • 8
  • 41
  • 69

2 Answers2

2

Absolute layout is deprecated. I suggest using something different.

This class is deprecated. Use FrameLayout, RelativeLayout or a custom layout instead.

http://developer.android.com/reference/android/widget/AbsoluteLayout.html

Edit: Answering to your comment:

Being deprecated means that for some reason, they stopped developing it. Maybe there's a better replacement, maybe they don't like the way it works. Anyway, they may drop this layout in future versions (which means your app won't be able to run in a future version of android).

Alternatives:

Frame Layout:

FrameLayout is designed to block out an area on the screen to display a single item. You can add multiple children to a FrameLayout, but all children are pegged to the top left of the screen. Children are drawn in a stack, with the most recently added child on top. The size of the frame layout is the size of its largest child (plus padding), visible or not (if the FrameLayout's parent permits). Views that are GONE are used for sizing only if setConsiderGoneChildrenWhenMeasuring() is set to true.

http://developer.android.com/reference/android/widget/FrameLayout.html

Relative Layout

You can also use a relative layout. Align every view by it's parent and set left and top margins as you wish. This may be your best option IMO. I've done this before and it worked reasonably well.

Community
  • 1
  • 1
Pedro Loureiro
  • 11,436
  • 2
  • 31
  • 37
  • I know it is deprecated. But does that mean that features of that layout doesn't work any more? And is there any good alternative layout where I can give x and y coordinates to childerenviews? – Peter Fortuin Jan 18 '11 at 13:09
1

As Pedro said, this feature may have been an addition that came after AbsoluteLayout's deprecation, so if it's not implemented already, it will never work.

As far as the comment "which means your app won't be able to run in a future version of android", Google has promised that this will NEVER be the case.

Dianne Hackborn

On Mon, May 4, 2009 at 10:00 AM, Sundog wrote:

I have a highly rated app that simply... could... not... be... written... without AbsoluteLayout, no matter whose Java sensibilities it steps on. I guess Android's doing so well with apps that it can afford to shut down an entire category of games.

Did AbsoluteLayout disappear from 1.5? No. Are you unable to write 1.5 apps using it? No. Have we ever said we have any plan to completely remove it at any point in the future? No. You need to find better reasons to be a victim. If you can't find one, let us know the name of your app and we can make sure to break it in the next release. Then you can -really- complain!
-- Dianne Hackborn
Android framework engineer
hack...@android.com

and later:

I'll say again: we are not going to remove AbsoluteLayout from a future release, but we strongly discourage people from using it.

I'd say it's a safe bet to say it won't be removed, but it also won't get new features/fixes either.

copolii
  • 14,208
  • 10
  • 51
  • 80