I'm developing an android app, I'm testing with samsung galaxy tab, for any reason my xxx_layout.xml is not working, it remains in its first version, if I modify it none of this changes are viewed, I make all the process to generate an signed apk, clear any data in the tablet before install but this problem still appearing.
Please any sugestion or solution is welcome, thanks
Greetings
Do you have another definition that is ovrriding this one?
Files in res/layout/ are "defaults" or fallback versions that are used when no better one is found. Now on a tablet,with a hdpi or xlarge screen, layouts in res/layout-hdpi or res/layout-xlarge are taken before the ones in res/layout.
can you make sure that this layout file is actually used.
also check if you have any errors in the layout file.
Related
I am getting duplicate files in my source code:
This happens quite often with Android Studio and it happens will all types of files, not just gradle files. It typically happens when I checkout a new branch or swith branches.
What is causing this and how can I prevent it?
As a note, this question was originally posted with image files, thus the image answers. However, this is not limited to image files and I understand why there are multiple image files for different screen densities. I have updated to reflect that there are other files being duplicated.
Do you have a Mac, and is your project stored in your "Documents" directory?
Filenames that include " 2" are generated by iCloud when it can't reconcile two versions of a file. E.g. if you have two computers, and both of them share their "Documents" directories via iCloud, and a file were to be changed simultaneously on both computers, iCloud would wind up creating e.g. a build 2.gradle file.
I found this was happening to me, even though I'm only using one computer to do my work. I suspect that Android Studio may be interacting with iCloud directly, not realizing that it's working on files that are already backed up on iCloud. (See Android Studio generating hundreds of duplicate " 2" files).
I seem to have fixed it by moving my project directory out of Documents. At any rate, I haven't had a problem since I did that.
(Credit to Mike M. for noticing the similarity between our problems.)
Since different devices support different screen densities, all non-vector image drawables should have an image asset for each type of density. So, from a development standpoint, you're using the same Drawable but the app will use the correct image size based on the screen density of the device the app is installed in. I suggest you take a look at this article for more information.
It's ok. Follow the every folder. Folder name is different according to possible phone size Different phone size is different, that’s why they support different size images.
I restart to develop an app which I stop to work on it years ago.
I would to move from Eclipse to Android Studio, but before I tried to check if it works with the Nexus5 I actually have. The app was tested on Nexus S.
After compiling and starting I get a lot of NullPointerException and I saw that depends on different findViewById not resolved.
I was using only the res/layout folder.
I tryed to copy that folder to a new folder named res/layout-large and all works fine.
My questions are:
Is there no way to use only res/layout ?
I have to rename it to res/layout-normal because res/layout isn't anymore the default layout folder, or not?
Do I need to introduce also the other folders (res/layout-normal and so on) ?
Thanks
Luca
-large -xlarge and so on have been deprecated for quite some time.
The documentation is not always up to date but it is recommended to use -sw<N>dp instead, for example layout-sw600dp
You don't have to use anything else than the base selector (layout, values, drawable, etc) for any kind of resource, so your problem seems to be in how you declare and use these resources.
While modifying a white label app, I needed to change a logo and found it was located in 2 locations (duplicated):
res/drawable and similar folders (for other screen depths)
bin/res/crunch/drawable and similar folders (for other screen depths)
So I would like to know if I should care about the second folder, or if it's something generated by Eclipse/ADT.
They are automatically generated on build. You can ignore them.
The crunch is used to export the app by eclipse and I've experienced a problem that a drawable was not updated in a crunch. If you want to be really sure that you deliver what you see, just clean the res/crunch/drawable before exporting.
Based on my experience, i believe that this is because of import from one machine to another one. (mostly, like 64-bit to 32-bit)
Just delete the folder crunch... activity will run fine.
I've added a folder called layout-976x600 in my android project for a resolution specific layout. All works fine, but I'm unable to preview the layout in Eclipse (4.2.1 Mac OS X Mountain Lion).
In the Graphical Layout tab, I just have a blank palette, viewing area, and the text "Loading editor" is forever displayed in the information box. Is it possible to get a preview here, or am I stuck doing work in the normal layout folder and moving once finished?
EDIT:
Ultimately this was fixed by renaming the folder. Oddly enough, if I renamed the folder, opened the file, renamed back and finally opened it again, it would sometimes work. Seems to be an issue with Eclipse. I should be using a legal identifier anyhow, so I marked that as the correct solution.
layout-976x600 is invalid name. There are only limited list of qualifiers you can apply to resource folders. This page will help you.
So I am not such a newbie in Programming, Java or Android developing, but I got a strange issue: I have made an application, quite advanced, and have it on market.
For now I have over 1000 installs and I have around 4 or 5 crash reports for a ResourceNotFoundException. The strangest thing is that the line it crashes on is on
setContentView(R.layout.some_custom_layout)
In code I am always referring to resourced by
someTxtView.setText(R.string.some_string)
So I am wondering if I used
mContext.getResources().getDrawable(mContext.getResources().getIdentifier("some_string", "string", "my.example.package"));
would the crash go away?
I was facing the same issue and I fixed it by creating Layout Folder called "layout-small".
Based on resolutions I have created only 2 folders "layout-large" and "layout-medium". But few phones are having lower resolution it doesn't find proper resources as per the resolution. Android OS renders xml resources as per resolution. It goes and find the resources in required folders.
95+ % Android phones having resolution which matches "layout-normal" folder. But still there are Phones having lower resolution. Hence this issue occurred.
For more Details : http://developer.android.com/guide/practices/screens_support.html
Hope this helps your problem.
If you are calling setContentView(R.layout.some_custom_layout) from the Activity's onCreate method, you should be good as long as your app compiles (and I assume it does).
AFAIK accessing your string resources via:
someTxtView.setText(R.string.some_string)
is not the way to go. You should be doing this:
getContext().getResources().getString(R.string.some_string)
Except
setContentView(R.layout.some_custom_layout);
try using
setContentView(yourpackagename.R.layout.some_custom_layout);
that helped me a lot of times.
I have one suggestion. Do you use in your layouts android secific resources, such as drawables or something, for example
android:backgroud="#android:drawable/some_android_drawable"
Maybe some vendors don't provide some resources with their firmware, so your app crashs.
for example this issue
someTxtView.setText(R.string.some_string)
There you set integer value to text. Its not correctly becouse it search a resousre on this value. You must write
someTextView.setText(getResources().getText(R.string.blabla));