android-resources

What is the use of the res/values/public.xml file on Android?

大城市里の小女人 提交于 2019-11-26 08:55:01
问题 I\'ve searched on Google, but couldn\'t find any relevant results. I also checked the official Android docs and this page (for all the available resources) was all I could find. The relevant links (to the res/values/ directory) I found on this page were: string resources style resources more resources These pages don\'t tell anything about the res/values/public.xml file. Here is an example I found for this type of file. Small snippet <?xml version=\"1.0\" encoding=\"utf-8\"?> <resources>

Android XXHDPI resources

左心房为你撑大大i 提交于 2019-11-26 08:47:23
问题 The Google Nexus 10 comes out shortly, and is the first device to use xxhdpi resources. It sports a display density of about 300 DPI (according to the Nexus 10 website and this calculator). However, when I go to the Android documentation, it states: ldpi : ~120dpi mdpi : ~160dpi hdpi : ~240dpi xhdpi : ~320dpi xxhdpi is not specified. How come the Nexus 10\'s 300 DPI screen is xxhdpi instead of xhdpi , and what should be the approximate DPI of xxhdpi ? Should we even worry about having new

Packaging Android resource files within a distributable Jar file

五迷三道 提交于 2019-11-26 08:44:19
问题 I am working on some reusable Android code that I would like to distribute to other developers for use within their own applications. The code has some resource dependencies (layouts, xml & png drawables) that I would like to be able to include and reference within a single package (Jar file). Is this possible, and if so what is the best method to do this? 回答1: I don't have any optimistic news for you. In general you cannot distribute your own package as easily as you would expect. The main

how to get images dynamically from drawable folder

泄露秘密 提交于 2019-11-26 07:57:49
问题 I have an array like this. int image[] = {R.drawable.d002_p001,R.drawable.d002_p002,R.drawable.d002_p003, R.drawable.d002_p004,R.drawable.d002_p005,R.drawable.d002_p006}; Right now I have 6 images so I am statically given the name. If I have some 50 images I cant give each and every file name in array so it needs to be dynamic how can I achieve this. 回答1: You can use getIdentifier() for (int j = 1; j < 6; j++) { Drawable drawable = getResources().getDrawable(getResources() .getIdentifier(

Lint: How to ignore “<key> is not translated in <language>” errors?

时间秒杀一切 提交于 2019-11-26 06:58:19
问题 I can\'t compile/debug our Android app, because the localization files are not perfect yet. My IDE\'s validation tool Lint create errors saying: newCardsOrderVals is not translated in ar, bg, ca, cs Compiling/installing/running with Ant works fine, but I would like to use my IDE to ease debugging. Is there a way to turn off this particular check, or ideally make it a warning rather than an error? I understand that before release we will really need to get localisation files right, but for the

getResources().getColor() is deprecated [duplicate]

筅森魡賤 提交于 2019-11-26 06:55:37
问题 This question already has answers here : getColor(int id) deprecated on Android 6.0 Marshmallow (API 23) (19 answers) Closed 3 years ago . Using: buildToolsVersion \"22.0.1\" , targetSdkVersion 22 in my gradle file. I found that the useful getResources().getColor(R.color.color_name) is deprecated. What should I use instead? 回答1: It looks like the best approach is to use: ContextCompat.getColor(context, R.color.color_name) eg: yourView.setBackgroundColor(ContextCompat.getColor

Load dimension value from res/values/dimension.xml from source code

社会主义新天地 提交于 2019-11-26 06:12:50
问题 I\'d like to load the value as it is. I have two dimension.xml files, one in /res/values/dimension.xml and the other one in /res/values-sw360dp/dimension.xml . From source code I\'d like to do something like getResources().getDimension(R.dimen.tutorial_cross_marginTop); This works but the value I get is multiplied times the screen density factor (1.5 for hdpi, 2.0 for xhdpi, etc). I also tried to do getResources().getString(R.dimen.tutorial_cross_marginTop); This would work in principle but I

When should I use the assets as opposed to raw resources in Android?

此生再无相见时 提交于 2019-11-26 06:04:49
问题 I\'m in the mid of my studies in the Android world, and I just covered the Assets and Raw resources. I\'m trying to understand the reason for using Raw resources vs. Assets. They both provide with an uncompiled resource input stream. It seems that Assets provide much more flexibility and functionality then Raw resources. a. You can create folder structure under Assets and not under Raw b. You can list all resources dynamically in the assets folder and not in the Raw folder. So, why would I

Duplicate value for resource &#39;attr/font&#39; with config "

一个人想着一个人 提交于 2019-11-26 05:35:59
问题 I really do now know why I got this error and how can I solve it. Actually I am not sure What I did right before I got this error . Error Msg: /Users/hyun/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.1.arr/25699caf34fef6313d6ec32013a1a117f/res/values/values.xml error:duplicate value for resource \'attr/font\' with config\". error: resource previously defined here /Users/hyun/Desktop/Laftel-Android/app/build/intermediates/incremental/mergeDbugResources/merged.dir/values/values.xml

How does the mapping between android resources and resources ID work?

余生长醉 提交于 2019-11-26 04:58:11
问题 It is magical for Android to locate the proper resource just through the R.id.XXX . AFAIK, the resources are compiled to binary format, so how does this mapping logic work under the hood? Maybe it works like this: For e.g., in the layout1.xml , we got: <Button android:id=\"@+id/button1\" > and AAPT will generate this in the R.java: public static final int button1=0x7f05000b; When the *.apk is genrated, the @+id/button1 with be substituded with \"0x7f05000b\". Thus, when we call: findViewById