How to set negative translationX before app load - java

when I set a view's translationX whether via XML or programmatically android seems to ignore the code.
When I run view.setTranslationX(-200); it ignores the translation and the app shows the view at 200 instead
If I run via post Runnable or overriding onMeasure it can be moved to -200 but it momentarily shows when the app loads. I don't want it to be seen on app start
What can I do to translate view before widget is shown.
When is the earliest I can set translationX?

The view/layout is not inflated yet so you can't.
Do you mind if I ask why you want to do it before the widget is shown?

Related

What does the `android.intent.extra.showActionIcons` parameter control?

I would like to take a photo with MediaStore.ACTION_IMAGE_CAPTURE intent, but disable the settings button in the top-left corner. I was able to find a EXTRA_SHOW_ACTION_ICONS parameter, but it is not well documented. This is the description:
The name of an Intent-extra used to control the UI of a ViewImage. This is a boolean property that specifies whether or not to show action icons.
Even if I set it true or false, nothing changes. What does this parameter do? I use it like this:
takePictureIntent.putExtra(MediaStore.EXTRA_SHOW_ACTION_ICONS, false);
I would like to take a photo with MediaStore.ACTION_IMAGE_CAPTURE intent, but disable the settings button in the top-left corner
As I have pointed out previously, you do not have control over the UI of a third-party camera apps. There are hundreds of such apps; none have to give you any ability to control their UI.
What does this parameter do?
Based on a search of the Android source code, it does nothing in Android itself. If the device happens to have the AOSP Gallery app installed, it appears to control something in the image viewer there. It is certainly possible that some non-AOSP apps use that extra for some particular reason, but that behavior would vary by app.

Why my emulator/device and design screen in AS show different layout ? I am concerned about the thing below 'BILL TOTAL'

Please click here to view the screenshot.Please tell me the reason. I can send you the codes if u require.
enter image description here
The design preview will not show any live running code or logic that the device or emulator will. You can override this by adding one of the tools references to the layout, but otherwise it will just use the default data set inside the XML layout attributes.

How to touch image button without getview or findViewById on Robotium?

I'm making auto test script(robotium) for android app (audio player)
but have some problems.
Touch event(getview, findViewById , clickOnView) don't work only when particular object is avaliable on screen.
I don't know what type of object it is... I'm not developer and I don't know about Java.
touch event test script like this
Button button = (Button)solo.getCurrentActivity().findViewById(com.packname.mirror.R.id.bt_menu);
solo.clickOnView(button);
Also android debug monitor can't dump view hierarchy when that particular object is available on screen - (Error obtaining UI hierarchy
Error while parsing UI hierarchy XML file: Invalid ui automator hierarchy file.)
so, I think getview, findViewById do not work only when particular object is available on the screen.
It seems need to find a way to touch image buttons without using getview or findViewById
Can't use axis touch method... many linear layout objects in app.
That cause problem when testing on various resolution devices.
In short, How to touch image button without getview or findViewById on Robotium ?
I don't have source but I have only R.java source(R.java maybe helping about it?)
please help me
(sorry for my bad English)

Google Maps Android -- How access default infowindow?

I have a map that shows a few points. If the user searches for a location instead of using their default location, a placemark will show for the searched location as well. This placemark shows the infowindow by default. All of these points are shown on screen (using a bounding box).
However, although I can account for the placemark to be shown on screen inside a bounding box, I am currently unable to make sure its infowindow is completely visible on screen. For example, if the placemark is the northeast-most item, its infowindow will be overflowing off the screen both on the top and the right.
Is there any way to get the infowindow of a marker? I know I can build one out using the CustomWindowAdapter and later access that view, but I don't want to customize it at all, just to be able to access it (and not just be able to call show or hideinfowindow() from the marker).
Ideally, I could get the height and width of the infowindow in pixels and use that to make sure it is always completely shown on screen.
No, you cannot. What you see as "info window" inside the map view is nothing more than a buffered snapshot (or a screen dump if you will) of the view created by your InfoWindowAdapter, meaning it's not a traditional view added to the view hierarchy, rather it's an image shown in the OpenGL context.
Accessing or manipulating this view after showInfoWindow() won't make any difference to what gets displayed on the map, at least until you call showInfoWindow() again to take a new snapshot.
It's the same reason you cannot add a long-click listener to the info window.

Change app background

I'm currently making an android app in which I'd like the user to be able to change the background image.
I've got 3 images and a screen where I can choose a picture and a button for applying.
The issue:
I can allow the user to see all images in the way I want, but I don't know how to set the selected image as app background.
What I want to do:
I want the user to click a button, which exports the selected image to "bakgrund.png" in "/res/drawable-mdpi" and replaces the current one. This would allow me to easily integrate the background switcher. Renaming of current files also works.
PS: My current background images are located in /res/drawable-mdpi named 1.png 2.png and 3.png.
Easiest way would be to call the setBackgroundResource(image_id) method on the root layout. Like if you have a LinearLayout which has android:id="#+linear" as the root layout in the layout xml, then this code will help:-
LinearLayout linearLayout=(LinearLayout) findViewById(R.id.linear);
linear.setBackgroundResource(R.drawable.1);//call this in the OnClickListener's OnClick Method
Firstly, you need different themes which has different backgrounds. So you may use this.setTheme method in your Activity.
Indeed I suggest you, two different layout (with different backgrounds but have same components) and using setContentView during onClick.
I hope it solves your issue.

Categories

Resources