Thanks for your answer, Romain. It's nice to know that I'm not alone in the (Android) universe ;)
In spite of the infinite loop, my application works. I haven't noticed slowness or any other issue except for the "misteryous" vanish of some paintings. Now thanks to you the misteryous it's revealed. By the way, do you know how could I avoid the limits given by the addView parameters so pagweb (WebView) repaints itself according to the size of addView parameters but without cutting its draw using its limits? I call super.onDraw(canvas) in ExtWebView, why it takes the pagWeb limits and not the ExtWebView ones? Thanks again. I appreciate your help. On 4 mar, 01:45, Romain Guy <romain...@android.com> wrote: > You are calling requestLayout() from the draw method. requestLayout() > causes a draw to happen, and you've just created an infinite loop. > > > > On Wed, Mar 3, 2010 at 4:42 PM, Alfonso <alfonsocris...@gmail.com> wrote: > > Well, I've found the way to replicate the avoiding cutting limits > > effect when rotate the ExtWebView. I just place a > > "this.layout(0,0,300,300);" and after it a "this.requestLayout()" at > > the end fo the onDrawMethod inside the ExtWebView class, looking so: > > > @Override > > protected void onDraw(Canvas canvas) { > > canvas.translate(0,320); > > canvas.rotate(-90); > > this.layout(0, 0, 300,300); > > this.requestLayout(); > > super.onDraw(canvas); > > } > > > I needed this effect, so I'm happy with this solution. But my doubt is > > still there, is the ExtTextView interacting with ExtWebView's canvas > > when setting the minimum heigth and width? Is this a bug? And another > > two questions, why ExtWebView continues painting its content even if I > > delete the "super.onDraw(canvas);" line at the end of the onDraw > > method? and why it doesn't work fine if I save and restore the canvas > > state at the begining and the end respectively of the onDraw method? > > > Thanks for your help. > > > On 26 feb, 04:37, Alfonso <alfonsocris...@gmail.com> wrote: > >> Hi, it's my first time writing here and I want giving thanks everybody > >> who makes the group possible. Specially to all the Android > >> developpers. Well, let's go to the problem: I'm trying to rotate a > >> WebView according with the orientation sensor. That's because below > >> this view I have a GLSurfaceView wich I don't want to rotate, so as > >> probably you'd have suppossed I set orientation in landscape mode, > >> avoiding the automatic rotate of the cell. > > >> To achieve my goal I include the class WebView in another one using > >> composition. This class is named, in example, ExtWebView and overrides > >> the onDraw method with canvas.rotate(-90) (after a translate). The > >> class ExtWebView extends the LinearLayout one. The problems begins > >> when I decide set the WebView in a non square portion of the screen > >> (not the whole one). So I add the WebView to the ExtWebView with > >> "addView(WebView, 200, 300);". In the main Activity I add the > >> ExtWebView with "addContentView(ExtWebView, new > >> LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));" so > >> it should being able to use the whole screen. > > >> And now come the problem. The rotated WebView appears initially fine > >> (rotated like expected), but if I slide my finger on it left or right > >> (coords are changed and works like up and down, but that doesn't worry > >> me) then only shows on the screen the portion of the View wich fits > >> into the bounds specified in the WebView with (200,300). In other > >> words, I rotate in the ExtVebView but it behaves like if I would the > >> WebView one (cutting the web page to its dimmensions). > > >> However, that's not the only one surprise (not the most interesting > >> one, at least for me). If I add a class wich extends TextView in the > >> main activity above the ExtWebView with the methods: setMinWidth(300) > >> and setMinHeight(300) (both of them inside the overrided onDraw > >> method) then ExtWebView shows the whole page rotated exactly like > >> expected, even behaves fine when sliding my finger on it, although the > >> portion of the web which before wasn't showed and yes now becomes > >> insensitive to my finger slidings. In a few words, with the > >> setMinWidth and setMinHeight methods the limits setted to 200x300 in > >> the WebView disappear. Is this a bug? Is there any other way of > >> achieving this effect? I`ve been looking inside the code of the > >> TextView and I think the question it is in the requestLayout() method > >> but I don't know where is implemented it's code. > > >> Any help will be wellcome. > > >> The code of ExtWebView is: > > >> public class ExtWebView extends LinearLayout { > > >> public ExtWebView(Context context) { > >> super(context); > >> mContext = context; > >> init(); > >> } > > >> public ExtWebView(Context context, AttributeSet params) { > >> super(context, params); > >> mContext = context; > >> init(); > >> } > > >> private void init() { > >> pagWeb = new WebView(mContext); > >> pagWeb.getSettings().setJavaScriptEnabled(true); > >> setWillNotDraw(false); //force the use of the OnDraw > >> method > >> addView(pagWeb, 200, 300); > >> } > > >> �...@override > >> protected void onDraw(Canvas canvas) { > >> canvas.translate(0,320); > >> canvas.rotate(-90); > >> super.onDraw(canvas); > >> } > > >> } > > >> The ExtTextView one: > > >> public class ExtTextView extends TextView { > >> public ExtTextView(Context context) { > >> super(context); > >> setText("Weird effect ..."); > >> } > > >> �...@override > >> protected void onDraw(Canvas canvas) { > >> canvas.save(); > > >> this.setMinHeight(300); > >> this.setMinWidth(300); > > >> super.onDraw(canvas); > >> canvas.restore(); > >> } > > >> } > > >> and we add the views in the main activity with: > > >> ExtWebView.loadURL("file:///sdcard/test.html") //Loading of the web > >> page > > >> addContentView(ExtWebView, new > >> LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));" > > >> addContentView(ExtTextView, new > >> LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));" > > > -- > > 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 > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them -- 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