This is a difficult one: I want to know where the buttons / textviews etc are located in the current focused activity which might not be mine. The app shall only run on my device so I can guarantee root / su and system-signatures + Android 4.2 and up (API 17).
I thought of getting a Screenshot via screencap or fb2png, passing it to an edge detection algorithm and look for squares, this would cover some views, better then nothing but this is not really satisfying me.
An other way would be to unpack the app, look for the layout files and parse them in what way ever (but if it has multiple layout files it will be very hard / impossible).
Thus Android must now which views are in foreground to make them touchable.
Where is this info stored? How can I access it? Or maybe other ideas?
Related
I am having trouble using android studio's drag and drop feature. I have no problem getting the items onto the preview mode of the android phone, but when I want to move the palettes, I can't seem to be able to place them where I want. A lot of times I will place let's say a TextView, and it will snap to a different location an inch away. Anyone know if any solutions?
Unless you know a way to un-snappy the editor, it's time to get to know the XML Text Editor, next tab over in Android Studio.
The way I get round the snappy side is in there: use the "android:layout_below="#+id/example" and it's brethren. Unless you have a massive amount of elements, this is very doable.
I am running calabash-android test for an android application. I need to attach images and videos to a particular section. I can reach the gallery section and after that, I could not select an item from the device library. Is there any way to keep a copy of video and image in my test directory and access the whenever needed? Or is there any solution to access the gallery. And one more thing is that I am integrating the test on Circle-ci later. And I don't know how can I manage it when it is on Circle-ci. All kind of help is appreciated.
Calabash only has access to your app, not anything outside of it.
You will be able to put together a solution using adb to interact with the screen, using touch or keyboard events. However, this will be tied to one specific screen size, as it's done by pixels.
adb shell input tap x y
You could put the images/videos in the directory so they are the most recent, then use adb touch events to select them? It's a bit hacky but it should work.
If I've understood your question correctly, the circle ci part should probably be split out into another question, as it isn't really tied to the previous bit.
EDIT: We ended up getting it to work by running
`adb shell input tap 200 200`
I'm working on UI automation tests for an Android app. I need to save off a screenshot of the app as it appears during various steps of the test for later analysis by test engineers.
The usual way to do this in Android is to get the Window, then get the DecorView, then call onDraw with a Canvas backed by a Bitmap and save the Bitmap. This doesn't work when a Dialog is showing on top of an Activity, however. The Dialog and Activity each have their own separate DecorView.
Is there any way to programatically take a screenshot of the entire app with all windows composited? Unfortunately, the device is not rooted and the app does not have signature permissions, so this answer in another thread does not apply:
https://stackoverflow.com/a/13837910/244521
For phone devices: This article shares some tips that might help. However, on ICS and above, you may need to use Home + Power, not Volume Down + Power, as the article says.
For automated tests, perhaps AutomatedScreenshots will help
What I want to achieve here is to shrink all of the Android's OS UI (everything inclusive) to use only 70-80% of the screen.
The reason is that I wish to have my area to put in whatever I want - apps icons which exist and are always visible (no matter if I am in a browser, or playing angry bird etc).. its like Windows's quick launch or Mac's dock which always stays there . I can also put some important text that I wish to see throughout my interaction with the device or anything else.
I just want to use 20-30% of the screen-size all by myself and run Android on the remaining portion of the screen.
Do you think it is possible? If so, can you please give me pointers?
Thanks much,
Rohan
There are two solutions for me:
1) create custom Android build. Change WindowManager code a little.
2) create own virtual keyboard which will serve keyboard and your stuff (http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html)
I am trying to develop an android application. I've put a scroll view as main container using graphical layout in eclipse. After that, I had put some UI elements, like buttons. When the total height of elements become more than viewable area, it can be seen using scroll view as expected. There is no problem until this point. The problem is the elements that are not fit viewable are of the screen can not be seen using graphical container of the eclipse interface. There is no problem with the source code, as it runs expectedly. Is there any option in the Eclipse gui to see the UI elements that are not fit the viewport?
I know what you're talking about. When you're viewing the xml file on the Eclipse Graphical layout you can only see the elements that fit on the screen. You can't scroll down to see the entire UI.
I use Eclipse at home and work. I'm using Eclipse Helios Service Release 1, on both systems. For some reason at home, when I'm on the graphical layout, there's a button on the upper right of the graphical viewer that says something like 'Remove Clipping'. (I'm at work now. So can't look to see exactly what it says).
When I click that button, I can now scroll down to see the entire UI. However, on my copy of Eclipse at work that same button isn't displayed. I've tried to figure out what the difference is between the setup on the two copies of Eclipse. But so far haven't been able to figure it out. Note, I've tried viewing the same exact xml file, within the same project, on both copies of Eclipse.
The problem seems to only occur when you're using a scrollview and all the ui elements won't fit on the graphical layout screen within Eclipse.
I have the same problem. I've been unable to troubleshoot, so I've resorted to using my physical device instead. I try to get the bulk of work done within the the Eclipse GUI... then nudge and polish with my device. Its a PITA to be sure, uploading what seems like a million times only to move one element a tiny bit more.
Best practices recommend developing on a device. Further, the Layout-tools && scrollView basically make it mandatory to really know what is going on. I can't seem to form this into a coherent search argument as my Google-fu has let me down on this one.
BTW - I'm using the shiny new r10 ADT plugin and I've been struggling with this for about 6 months.
Another workaround: You can use a smaller-ish tablet port in the GUI to get a really rough idea of what you are working with.
If your target layout is for a phone or smaller device, simply switch the preview to a larger screen size configuration.
In the upper left corner, under where it says 'Editing config: ~default', The list provides you with a number of screen sizes to target. Pick the 10.1 in version, and it will scale the preview, and will then allow you to see and work with all of the views that have scrolled off the screen.
Cheers-
I think this is an old topic but I was having the same issue. I have 2 apps made from outsourcing. when I opened each in eclipse one would show the full contents of the scrollview and one was clipped off. After numerous google searches nothing came up as a solution. I just happen to look and saw the app that is clipped was android version 1.6 and the app that shows everything like i wanted it to so I can use the graphical layout for a scrollview was android verion 2.1.
So i changed the one app to version 2.1 and it fixed it. noone seemed to address that. so for me the fix was make sure the android version you are building for is 2.1. you can always change it back to 1.6 compatable after you are done designing.
Hope this helps
The best way i could figure out is to give negetive top margin to the root layout that will make the rest of the content visible. This is only for dev purpose and should be removed when completed