ok so here I have a difficult one. apparently no1 does know a thing about this issue but I did find some app implementing the behaviour so hopefully...
I'll keep this short as I am sure if you stumbled upon it too, then you'll recognize the issue straight aways.
I have a horizontal Gallery with SrollViews in it. The 2 onTouchEvents (the one of the gallery and the one of the scrollview being displaied) collide and you need to take a decision about who to dispatch the event to.
anyone!?
please if u have no idea what I am talking about please let the http alone ... it's already busy enough ;)
I have a horizontal Gallery with
SrollViews in it.
That is unlikely to work, for the reasons you discovered. Most likely, you will need to replace one or the other. For example, you could use a ViewSwitcher or ViewFlipper instead of a Gallery. I have also heard that ScrollView and HoriztonalScrollView actually work OK together, though I have not tried it.
Related
Ok, so...
I know, there's been a real amount of questions about it, but it either didn't work, or was really fixed in a hard way. Oh, and that's my second day trying to do it, so please, accept my apologies about that and help me for Chet Haase's sake.
I have a button on top of a fragment, and a RecyclerView below it. When i press the button i want it to disappear and a new RelativeLayout with textfields to slide from the top.
I don't want to make it with animateLayoutChanges="true", cause it's not exactly what i was meant to do, and i want rather learn, than do it.
I tried to do it with widget.animate().translation... and the result was that one widget was just thrown in it's place when the rest of layout stood still. That's not what i meant to do.
I tried also to make an "new TranslateAnimation" since it has this "setFillAfter/Before" attribute... but that did not help me neither.
What i tried as well was to update the layout somehow adding to id margins and stuff (don't remember anymore, and i'm in work right now trying to figure it out, sorry) as it was described in some questions.
But none of that worked. I don't include code right now, cause i already tried to do it in some dozens of different ways.
Could you please tell me how to move a widget and make the rest of them to move with it? Is it possible?
I've already got it going once using setVisibility,animateLayoutChanges and animation combination, but that was massive and dirty as a baby duck.
Edit: oh, i almost forgot about it. Another problem is that when i animate/move a widget, only the rendering spod changes, but the real spot of it stays the same (ex. a onclicklistener)
Ok, me again.
I did it this way, that - let's say - i want to slide a button up and remove it.
So i animate it and all the other widgets (right, i can make a ViewGroup) up, put a listener on animation, and on "onAnimationEnd" i clear all the animations and set the visibility to GONE.
The animateLayoutChanges must be set to false
Still it's not what i wanted, so i'd be indebted to anyone who shows me another, better way.
this is my ImageButton. my confusion is that i do not know how to determine whether the user clicked on the Login half, or the Sign up half, so i can take them to the respective Activity. i would be incredibly grateful if somebody can 1) name a resource i can use to learn on my own, or 2) explain the process of finding view locations and any possible algorithms used to determine if a click was in bounds of a specific portion of a View or not.
You should divide your button into 2 different ones, and process clicks separately.
Have 2 image buttons and try to achieve the same look and feel you want.
In your case, even though this kind of thing is doable. It is expensive and complicated and unnecessary. And you will have problems with styling of the buttons (eg: focus)
Edit:
Yes I understand, But I suggest you not to over complicate things. Because, your device has limited resources (eg: battery),
But you can still get the experience on how to create a circle like button with two sides on it, using 2 buttons which is still exciting :D.
my question is not only about onTouch events but about every method I can use to recognise a touch on certain areas of the screen.
Right now, I have a "background" image, which I use as layout that contains 2 "buttons": Start and Options as you can see here:
Ok, what I want to know is which is the best way to identify when are the user touching each button. By the way, should be nice also some info about how to deal with the different screen sizes.
Lots of thanks.
PD: seems I didnt explain it well. they are not "Android buttons" theirselves. The background is a whole image, where you can find 2 "buttons", but they are a part of the image. Thats because I need to know how to do this
I think you're missing some fundamentals, so I recommend to take a tutorial track.
As a direct answer to your question , you can see this page from the tutorial.
Why do you want to set the touchListener on whole screen and find the buttons?..You can simply set the OnClickListener or onTouchListener on both the buttons itself..
Background
There are some nice apps out there that show some layout on top , while the user is making a call or answering one (like "current caller id").
I need to create an app with the ability to show something on top , during a call, and allow it to be interactive.
The problem
Using broadcastReceiver ,foreground service and SYSTEM_ALERT permission, I've succeeded showing something on the screen during calls.
As long as the content being shown is static, I have no problems.
However, I've noticed that when I try to make the content being shown to be interactive , I face some problems:
Everything is jumpy and this includes not only animations, but also setting visibility to visible/gone. I hate to think how it would work like when I need to make things draggable.
Not sure if this is the reason, but using the SlidingDrawer make the entire width belong to the SlidingDrawer and you cannot click through it. This means that if its location is at the bottom, you can't touch the "answer" button when someone calls you.
The question
What is the reason for those problems?
How can I fix them and be able to show things right?
How do other apps handle it right ?
EDIT: about the SlidingDrawer , it seems that it has terrible bugs about its location and size, and the content area, even when it's not shown to the user and the user can see through, it cannot be touched through. Still, I don't know why, and how to fix it, and I also don't know why things are so jumpy compared to normal apps (probably because of over-drawing, but it's really really slow).
Maybe this question should be more general: how to make a floating window like on AirCalc, that can be moved easily yet still be quite fast.
For the dragging functionality, I've tried to get the layoutParams of the root view (which is of type WindowManager.LayoutParams ) that I show, update it and set it again, but for some reason it didn't do anything. Wonder what I'm doing wrong.
EDIT: it seems that i should be using windowManager.updateViewLayout for updating the layoutParams. Using this post , I've made it perfectly draggable.
Ok, I've come up to some conclusions about this, first to answer my original questions:
it's probably because of overdraw and the views i've used. I wanted to try out libraries that could replace the slidingDrawer , but each had a different problem. using simple views proved that the idea in general works.
in the case of visibility changes, it was jumpy because the size of the view wasn't able to fit using the current WindowManager.LayoutParams size.
slidingDrawaer does have issues since it uses the whole size it get when closed or opened.
now to the rest of the issues :
unable to drag ? instead of the regular setLayoutParams , use windowManager.updateViewLayout .
unable to touch outside of the view ? set its minimal size according to your needs. you can also set the window flags so that touch event would go through .
want to listen to calls events ? you can use the broadcastReceiver for triggering the showing of the app, but I suspect that hanging the call might cause the intent be received later sometimes. I think you can use telephonyManager and listen to events there, using the service you run in the foreground (that i've created just to make sure the app won't close in the middle).
if anyone else has questions, i can help.
any idea how to implement something like the multiple desktops of the android?
I tried Gallery but it sucks I wansted something just like the desktop app
thanks
have you tried using <ScrollView>? I've never tried this so i dont know if its possible, but you might try sticking some layouts in a ScrollView and then listen for the scroll event. When the scroll event happens, you can then automatically scroll them from 1 view to the other so that they never end up half way between one or the other... if you try this, please post the code, i'd be interested in seeing how you do it...
In my case I used this tutorial :
http://developer.android.com/training/animation/screen-slide.html
It works very well but there is still the large background image sliding a bit at each page change to do.