android-resources

Why does Android's Nexus 7 virtual device not load my “large” layout resources?

限于喜欢 提交于 2019-12-11 10:36:24
问题 Using the Nexus 7 in AVD, my layout-large resources are not being loaded. I thought that 7-inch devices fell into the "large" category. I have a physical device, the Galaxy 3 Lite, which is 7 inches and loads my "large" resources. I would post some XML, but I feel it should be a straight-forward "7 inches is considered large" issue... Thanks! EDIT: The expected "large" layout is used in my Genymotion emulator. So why not in the AVD? 回答1: I had the same problem and the solution exists : you

Android resource qualifiers for Huge/Small fonts (accessibility)

一曲冷凌霜 提交于 2019-12-11 10:36:02
问题 I have searched the documentation and have not found an answer so here we go: Does Android have a resource qualifier to select between different resources when accessibility options are used? Like when the user sets font size to Huge. I would like use different dimensions on some views when dealing with Huge/Small fonts. Thanks in advance! 回答1: No, there is no resource qualifier for font scale. I assume you're aware of the sp unit for specifying text size. I would suggest either - Make your

No RelativeLayout id in R.id while Getting dimensions of RelativeLayout

╄→гoц情女王★ 提交于 2019-12-11 09:42:50
问题 I am trying to get the dimensions of my RelativeLayout . I am told by many to use the following codes: RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.myRelativeLayout); int layoutWidth = relativeLayout.getWidth(); int layoutHeight = relativeLayout.getHeight(); My problem is that all the ids I can find in my R.id are all buttons, text views, and all that kind. There is nothing like layout id at all! Then I try to write: relativeLayout = (RelativeLayout) findViewById(R

Get drawable for different screen density at runtime

旧城冷巷雨未停 提交于 2019-12-11 08:57:03
问题 I want to print sizes of all drawables at run-time. So if I am on hdpi device then I can print the size of hdpi drawables but how to get access to, lets say mdpi and xhdpi as well? I can get access to all drawables resource ids with following code: final Class<R.drawable> c = R.drawable.class; final Field[] fields = c.getDeclaredFields(); for (int i = 0, max = fields.length; i < max; i++) { final int resourceId; try { resourceId = fields[i].getInt(drawableResources); } catch (Exception e) {

RunTime Localization (Multi-language) not working on some devices ex. Oppo f9 and Huawei y9

夙愿已清 提交于 2019-12-11 08:49:04
问题 I implemented the following Localization logic in order to be able to change the language of my app dynamically from English to Arabic and vice-versa. It is working on all emulator versions from 5.1 up till 9.0, and on all of my 7 physical devices. The problem is that i get complains from users specifically using devices like Oppo f9 and Huawei y9 (2019) that when attempting to change the language, the layout direction changes, however the app doesn't use the other string resources. It is

Share drawables between applications

旧城冷巷雨未停 提交于 2019-12-11 08:09:17
问题 I have implemented plugin system in my applications. Plugins exist as the standalone applications. What is the best way to access drawables from plugins in main application ? 回答1: You have few options: ContentProvider - not definitely need to be based over SQLite database. manifest attribute android:sharedUserId From docs: The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is

Copy files inside Android internal memory

对着背影说爱祢 提交于 2019-12-11 08:05:55
问题 I am writing an Android application and I need to copy 2 files into the device' s internal storage. Currently I am able to run my application after manually copying these two files under the device' s "/data/data/[my_package_name]/files" folder using DDMS. I need to put these two files into that folder(or any folder) while my application is being installed on the device. The tip here says files within the "res/raw/" directory will be deployed to the device and will be accessible through

dynamic Bitmap drawable in android

狂风中的少年 提交于 2019-12-11 07:08:18
问题 I am wondering how i can set a Bitmap drawable resource from a dynamic variable that is the image name/ type string: public CustomIcon getView(int position, View convertView, ViewGroup parent) { String label; String image; DataBaseManager db = new DataBaseManager(context); label = db.getIconLabel(mIcons.get(position)); image = db.getIconImage(mIcons.get(position)); Bitmap bitmap = BitmapFactory.decodeResource(parent.getResources(), parent.getResources().getIdentifier(image, "drawable",

Storing configs in android

若如初见. 提交于 2019-12-11 05:47:10
问题 I'm trying to work out where the best place to put config type data is. At the moment everything is hardcoded in java e.g API endpoint URLs, API keys etc. Can they just go in strings resources? or in a static class? side note - is it safe to keep API keys like this? 回答1: There are some options to use: 1.Static class (something like Config.java) or singleton object. For example: public enum Config { INSTANCE; public static final String CLOUD_ID = "8888888888"; } 2.String resources (strings.xml

Resource not found: res/drawable/list_selector_background.xml?

二次信任 提交于 2019-12-11 05:17:06
问题 I recently released my first app. Having only tested in SDK emulator and on a Galaxy S2, the feedback about devices it works on coming to me has been great. Unfortunately I've had a couple users report FCs to me. The common factor between them is that they are both MIUI users (different devices IIRC). One has been very helpful in providing info and trying out sample builds to resolve the issue but I just can't seem to make any headway on it. I've searched online fairly extensively. Although I