[android-developers] Re: GridView
I'm interested in this question aswell, and how you can set the height of each row for that matter, would be nice not to have to reimplement the whole GridView. Regards, //Erik On Dec 9 2008, 10:42 am, Andriy Zakharchuk andriy.zakharc...@gmail.com wrote: Hello Xavier, what I'm trying to do is to get android.widget.GridViewstretched to screen. private LinearLayout panelContent = null; privateGridViewgridViews = null; ... panelContent = new LinearLayout(this); // Custom adapter implementation ListAdapterImpl adapter = new ListAdapterImpl(); gridViews = newGridView(this); gridViews.setAdapter(adapter); gridViews.setNumColumns(2); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 1 ); panelContent.addView(gridViews, lp); setContentView(panelContent); In this caseGridViewcovers all the screen, however, grid item views take as much space as they need. What I'm trying to get. Lets imagine the screen is in the portrait mode, screen size (to make it simpler - grid view height) is 480 pixels.GridViewhas two colums. Then: - when I have 1 or 2 elements (1 row) row height should be 480 pixels. - when I have 3 or 4 elements (2 rows) row height should be 240 pixels. - when I have 5 or 6 elements (3 rows) row height should be 160 pixels. - and so on. I can not control grid view item height with ListAdapter.getView(). I looked into AbsListView.generateLayoutParams(), but it work with AbsListViewLayout params which doesn't support smth like weight. So I was not able to redistribute extra space(height) between grid view items. On Dec 1, 9:46 pm, Xavier Mathews xavieruni...@gmail.com wrote: Where are you trying to stretch this? I believe you can if you are talking about android i can go see for you. Xavier A. Mathews Student/Browser Specialist/Developer/Web-Master Google Group Client Based Tech Support Specialist Hazel Crest Illinois xavieruni...@gmail.com¥xavieruni...@hotmail.com¥truestar...@yahoo.com Fear of a name, only increases fear of the thing itself. On Mon, Dec 1, 2008 at 8:47 AM, Andriy Zakharchuk andriy.zakharc...@gmail.com wrote: Hello all, I have a question about grid view: is there any chance to stretch GridViewvertically. What I'm trying to do is to create a screen with a limited number of items (6). I need exactly 2 columns and 3 rows (or 3x2 in landscape mode) to fill all the screen. In a grid view I can control columns number, and columns stretching mode, but not rows. I'm looking into overriding AbsListView.generateLayoutParams() method, but want to ask first. Probably, there is some simpler way available. Thank you 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-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Custom animation doesn't invalidate the area correctly
For anyone else interested, I have now found the solution. While I'm still improving my solution the problem was that the old child was placed in mDisappearingChildren and was therefor painted by the main view even after I thought it was removed. Send me a message if you have a similar problem and like to get more details. Regards, //Erik On Sep 1, 11:00 pm, Erik Calissendorff [EMAIL PROTECTED] wrote: Hi again Romain and thanks for your quick responses, Let me try to explain the setup further: I have a rootView which contains a few ViewGroups. When an item is dragged it is removed from the ViewGroup which it originally belonged to and added to the rootView instead, the dragged item is then what is called the mEditView in my code. When the dragged item is released it is added to the ViewGroup which it is currently positioned over or if not accepted there returned to it's original location and ViewGroup. As long as the item is dragged around the rootView.getChildSta... is responsible for drawing it in the right place, this is acheived with the help class of mEditTransformationHelper which enables some simple animation of the movements. By implementing this simple form of private animation I can at any time locate where the View is drawn, which I need to know when the dragged item is released. The tricky part is when the view gets released, it then is removed from the rootView and reinserted into one of the ViewGroups. My custom animation is responsible for smoothly moving the dragged view from the drop location to the actual location that it is assigned to (currently using a grid layout so some adjustment will be made from the actual drop location). The custom animation is given the absolute location of the dragged view before it is removed from the rootView. Once the animation is initiated it will recalculate the coordinates to correspond with the new assigned location of the view, this works really well with the exception following. The problem is that if the dragged view is partially (or even fully) over another ViewGroup than the one it will be assigned to after the drop, that other ViewGroup is not invalidated and the part of the view that was visible over the other ViewGroup will remain visible while and after the animation is finished. The question is therefor how I can ensure that either the entire rootView is invalidated (during animation) or which other approach that could be advised. Below are the relevant code snippets from the key functions and classes: rootView.getChildStaticTransformation(View child, Transformation t) { [...] if(child == this.mEditView) { Transformation tr=new Transformation(); tr.set(this.mEditTransformation); [...] //Update the tr transformation this.mEditTransformationHelper.apply(tr); this.invalidate(); [...] t.compose(tr); this.mEditTransformation.set(t); returnValue=true; } [...] } customAnimation.applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); Misc.updateTransformation(t,this.mWork,interpolatedTime,true); } mEditTransactionHelper.apply(Transformation source) { [...] for(...) { [...] //Update the source transformation Misc.updateTransformation(source,tr.mTargetTransformation,completed); [...] } } Misc.updateTransformation(Transformation source,Transformation target,float progress,boolean reverse) { [...] if(target.getTransformationType() == Transformation.TYPE_BOTH || target.getTransformationType() == Transformation.TYPE_MATRIX) { [...] float [] sourceMatrix=new float[9]; source.getMatrix().getValues(sourceMatrix); float[] targetMatrix=new float[9]; target.getMatrix().getValues(targetMatrix); for(int i=0;i9;i++) { sourceMatrix[i]=sourceMatrix[i]+(targetMatrix[i]- sourceMatrix[i])*progress; } source.getMatrix().setValues(sourceMatrix); [...] } } On Sep 1, 9:50 pm, Romain Guy [EMAIL PROTECTED] wrote: Hi, It's hard to tell what's going on with such a succinct description. Could you show some code if possible
[android-developers] Re: Gesture detection
Hi Kingtut, I believe that this code should work for you, I use this solution in my Activity: @Override public boolean dispatchTouchEvent(MotionEvent ev) { boolean returnValue=false; returnValue=returnValue | mGestureDetector.onTouchEvent(ev); returnValue=returnValue | super.dispatchTouchEvent(ev); return returnValue; } Good luck with the development. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] How to enable getChildStaticTransformation in 1.0_r1
In 0.9 I used this.mGroupFlags |= FLAG_SUPPORT_STATIC_TRANSFORMATIONS; in a custom ViewGroup to enable my own implementation of getChildStaticTransformation(...) but since this.mGroupFlags is depreciated in the new release (1.0_r1) I wounder how I should enable getChildStaticTransformation(...) now. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] How to enable getChildStaticTransformation in 1.0_r1
In 0.9 I used this.mGroupFlags |= FLAG_SUPPORT_STATIC_TRANSFORMATIONS; in a custom ViewGroup to enable my own implementation of getChildStaticTransformation(...) but since this.mGroupFlags is depreciated in the new release (1.0_r1) I wounder how I should enable getChildStaticTransformation(...) now. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom animation doesn't invalidate the area correctly
I'm creating a custom animation which extends Animation and overrides applyTransformation(float interpolatedTime, Transformation t) I'm also overriding getChildStaticTransformation(View child, Transformation t) in a rootView which I use for drag'n'drop. When I move a view outside of the drop parent before I initiate my custom animation the original position of the view is not cleared. If I modify my custom Animation so it doesn't modify the Transformation the original location is cleared as expected. So my question, how should I implement my custom animation so it will invalidate the area correctly? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Custom animation doesn't invalidate the area correctly
Hi again Romain and thanks for your quick responses, Let me try to explain the setup further: I have a rootView which contains a few ViewGroups. When an item is dragged it is removed from the ViewGroup which it originally belonged to and added to the rootView instead, the dragged item is then what is called the mEditView in my code. When the dragged item is released it is added to the ViewGroup which it is currently positioned over or if not accepted there returned to it's original location and ViewGroup. As long as the item is dragged around the rootView.getChildSta... is responsible for drawing it in the right place, this is acheived with the help class of mEditTransformationHelper which enables some simple animation of the movements. By implementing this simple form of private animation I can at any time locate where the View is drawn, which I need to know when the dragged item is released. The tricky part is when the view gets released, it then is removed from the rootView and reinserted into one of the ViewGroups. My custom animation is responsible for smoothly moving the dragged view from the drop location to the actual location that it is assigned to (currently using a grid layout so some adjustment will be made from the actual drop location). The custom animation is given the absolute location of the dragged view before it is removed from the rootView. Once the animation is initiated it will recalculate the coordinates to correspond with the new assigned location of the view, this works really well with the exception following. The problem is that if the dragged view is partially (or even fully) over another ViewGroup than the one it will be assigned to after the drop, that other ViewGroup is not invalidated and the part of the view that was visible over the other ViewGroup will remain visible while and after the animation is finished. The question is therefor how I can ensure that either the entire rootView is invalidated (during animation) or which other approach that could be advised. Below are the relevant code snippets from the key functions and classes: rootView.getChildStaticTransformation(View child, Transformation t) { [...] if(child == this.mEditView) { Transformation tr=new Transformation(); tr.set(this.mEditTransformation); [...] //Update the tr transformation this.mEditTransformationHelper.apply(tr); this.invalidate(); [...] t.compose(tr); this.mEditTransformation.set(t); returnValue=true; } [...] } customAnimation.applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); Misc.updateTransformation(t,this.mWork,interpolatedTime,true); } mEditTransactionHelper.apply(Transformation source) { [...] for(...) { [...] //Update the source transformation Misc.updateTransformation(source,tr.mTargetTransformation,completed); [...] } } Misc.updateTransformation(Transformation source,Transformation target,float progress,boolean reverse) { [...] if(target.getTransformationType() == Transformation.TYPE_BOTH || target.getTransformationType() == Transformation.TYPE_MATRIX) { [...] float [] sourceMatrix=new float[9]; source.getMatrix().getValues(sourceMatrix); float[] targetMatrix=new float[9]; target.getMatrix().getValues(targetMatrix); for(int i=0;i9;i++) { sourceMatrix[i]=sourceMatrix[i]+(targetMatrix[i]- sourceMatrix[i])*progress; } source.getMatrix().setValues(sourceMatrix); [...] } } On Sep 1, 9:50 pm, Romain Guy [EMAIL PROTECTED] wrote: Hi, It's hard to tell what's going on with such a succinct description. Could you show some code if possible? It looks like you are simply not invalidating the drop parent correctly. On Mon, Sep 1, 2008 at 10:37 AM, Erik Calissendorff [EMAIL PROTECTED] wrote: I'm creating a custom animation which extends Animation and overrides applyTransformation(float interpolatedTime, Transformation t) I'm also overriding getChildStaticTransformation(View child, Transformation t) in a rootView which I use for drag'n'drop. When I move a view outside of the drop parent before I initiate my custom
[android-developers] Custom LayoutParams?
Hi, I have created a custom ViewGroup and would like to have a custom LayoutParams together with it so I can assign these to the children through the XML. I have created a custom LayoutParams class and added the following to my attrs.xml: declare-styleable name=LayoutParams attr name=column_span format=integer / attr name=row_span format=integer / /declare-styleable I can use the xml tags in my children from my layout.xml with: app:column_span=2 app:row_span=2 But I do not understand how the inflate process should be able to understand that it should create my type of LayoutParams (it doesn't at the moment). If I only had my own type of children I could override the inflate process, but that can't be the preferred way? Any ideas how I correctly should create my own ViewGroup with associated LayoutParams that can be used from xml? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Drag Drop outside the parent ViewGroup
Hi I'm implementing some drag drop functionality. I'm currently having two problems: 1) When I drag the View outside of it's parent it's being clipped, I like to be able to drag the item around the whole window. 2) Z-order, I'm currently bringing the dragged View to the front but with the same approach when moving over view groups would mean that the parent ViewGroup would have to be at the front potentially resulting in distorting the layout of the application. Question: Is there a way to hand over the drawing of a View to my root View or even the activity so it can be ensured to be at the front and move around the whole window? I would prefer not to have to remove the child and add it into an other ViewGroup during the drag drop operation if possible. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: I want to gain the coordinate when i touch on the screen,how to?
Did you try: event.getRawX() event.getRawY() On Aug 21, 3:48 am, China-jlu-wangliang [EMAIL PROTECTED] wrote: yeah,i have tried to use the functions that you said,but when i pressed on the button i can't get the raw coordinate. On 8月18日, 下午12时10分, andylau [EMAIL PROTECTED] wrote: hi, try to use flows event.getX(); event.getY(); On Aug 1, 11:35 am, China-jlu-wangliang [EMAIL PROTECTED] wrote: I knowonTouchEvent(MotionEventevent) ,but when i press a button,if i can get the coordinate by usingonTouchEvent(MotionEvent event) ,and how to do that.- 隐藏被引用文字 - - 显示引用的文字 - --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Draw children manually in custom ViewGroup
Thanks, that was a much easier way to modify the views at drawing. Some tips which I learned as I tested this approach: You indicate that the ViewGroup supports static transformation with: this.mGroupFlags = this.mGroupFlags | FLAG_SUPPORT_STATIC_TRANSFORMATIONS; For the modified transformation to be performed you should return true from: boolean getChildStaticTransformation(View child, Transformation t) Kindest regards, //Erik On Aug 14, 5:12 pm, Romain Guy [EMAIL PROTECTED] wrote: You need to translate the canvas to the right position for each child and take into account the scroll offsets. I highly advise against overriding dispatchDraw() because it does a number of delicate things. The next version of the SDK will make ViewGroup.drawChild() protected so that you can override dispatchDraw() more safely. To move, scale and apply transparency to your Views at drawing time, it's a lot simpler than what you are doing. You can simply override the getChildStaticTransformation() method (I'm not sure of the exact name) and make sure your ViewGroup indicates it supports static transformations. Then simply return the appropriate Transformation that translates, scales and applies alpha. This is what Gallery does for instance. On Thu, Aug 14, 2008 at 5:15 AM, Erik Calissendorff [EMAIL PROTECTED] wrote: I'm trying to draw the children manually in my custom ViewGroup but the code below only displays the left top most child. I have tried not to clip the canvas and simply just call the child draw(Canvas c) method directly but that results in that all children are drawn on top of each other. What I like to accomplish is to be able to manually move,scale and modify the transparency of theViewat each draw call from the parent. I hope that someone can inform me how to make this work. Below is a my onLayout and dispatchDraw functions as they are now. @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { for(int i=0;ithis.getChildCount();i++) { Viewchild = this.getChildAt(i); Rectrect=this.mCellPositions[i]; child.layout(rect.left,rect.top,rect.right,rect.bottom); } } @Override protected void dispatchDraw(Canvas canvas) { for(int i=0;ithis.getChildCount();i++) { Viewview= this.getChildAt(i); Rectcell=this.mCellPositions[i]; canvas.save(); if(canvas.clipRect(cell,Op.REPLACE)) { if(!canvas.quickReject(view.getLeft(),view.getTop(), view.getRight(),view.getBottom(), EdgeType.BW)) { view.draw(canvas); } } canvas.restore(); } } -- Romain Guywww.curious-creature.org --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---