android-resources

Get integer value from dimens.xml resource file in Android

左心房为你撑大大i 提交于 2019-12-04 03:08:49
问题 I have an EditText which is decimal and I set its length using android:maxLength property in xml: <EditText android:id="@+id/quantity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="numberDecimal" android:singleLine="true" android:maxLength="@integer/quantity_length" /> As its length is going to be used not only in the UI xml file but also in a java class and maybe some other places, I want to avoid problems when I update this

How to make Android library resources private?

不羁的心 提交于 2019-12-04 02:37:14
How do I make the resources (string, dimen, color, etc.) in my Android library module private? I've tried both documented ways of doing this and neither work... Following the official Android doc of creating a res/values/public.xml does not work; all of the resources remain public in the app that uses this library. Following Chris Banes's instruction (and reiterated in this StackOverflow answer ) of creating a res-public/values/public.xml folder does not work either; all of the resources are made private, but those listed in the public.xml file are not made public as they should be. Does

Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse

拈花ヽ惹草 提交于 2019-12-04 02:33:47
I'm creating an Android app in Android Studio. When I open the layout editor, I see that gray "popup window" on top of the layout, which says that it Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse. This happens when I change the "rendering version" to API 15 ( Android 4.0.3 ). It worked a minute ago, but when I switched back to the layout, I just got this error. Edit: I use the AppCompat library. The theme is defined like this <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar" /> The app works fine when I run it, but doesn't render correctly (at

Adding layout resources to androidTest

孤人 提交于 2019-12-04 02:28:43
I would like to add layout xml files into my androidTest folder to be used only for testing. I added res/layout folder to androidTest and tried to add a layout file to it. But it gives error URI is not registered for xmlns:android="http://schemas.android.com/apk/res/android" Somehow the project does not recognize it as valid layout file. It is tricky to add xml resources to androidTest . Android Instrumentation tests create another APK to run the tests against your original application. Although you can access your Context and objects from your main application, you cannot modify the generated

How to get programmatically list of supported languages in an Android project (NOT device)

对着背影说爱祢 提交于 2019-12-04 01:52:05
In some project we can have this situation How to get programmatically list of supported languages by this app/project? As the result I need string array like this { "en", "bg", "bs", "da", "de", "hr", "it", "nl", "pl", "pt", "sk", "sr", "tr" } Of course I can hardcode it by typing it but I suppose code can and should do it. And why I need it - I have a separate library that deals with localization, instant change of UI after selecting new language etc. App must tell library which languages it supports. And it's nice just to add new xml for a new language without changing code (updating that

BitmapFactory.decodeResource and drawable* folders

╄→гoц情女王★ 提交于 2019-12-04 01:20:38
I am wondering if decodeResource (Resources res, int id, BitmapFactory.Options opts) takes into account the drawable-ldpi,mdpi,hdpi etc. folders. I checked the source code, and it doesn't look like that, but I may be missing something. (Generally, where are the R.drawable. resolved in Android source? I was unable to find it.) Yes it takes it into account. For example if you do : Resources res = getContext().getResources(); int id = R.drawable.image; Bitmap b = BitmapFactory.decodeResource(res, id); The bitmap will be different if "image" is present in all of the drawables folders. So I think

Missing XML resource type for PercentRelativeLayout Percentage value?

对着背影说爱祢 提交于 2019-12-04 01:01:16
It seems that the new Percent Support Library was released without allowing to reference a Percentage value in a dimension xml file. That is, instead of : <android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"/> <ImageView app:layout_widthPercent="50%" app:layout_heightPercent="50%" app:layout_marginTopPercent="25%" app:layout_marginLeftPercent="25%"/> </android.support.percent.PercentFrameLayout/> being able to code

Which part of Android is in charge of picking a correct resource profile?

喜你入骨 提交于 2019-12-04 00:58:17
问题 I have a weird problem. Before you come to an idea to lash out on me, I am working on a custom Jelly Bean. Therefore the "usual nice approaches" might not work here, and dirty workarounds have to be made. I have an APK which contains the following in assets: layout layout-mdpi layout-land layout-large-mdpi layout-large-land-mdpi layout-large-hdpi layout-large-xhdpi And some other metrics code returned this: D/AppDemo( 2091): measured width: 1920 PE width: 1920 scaleFactor = 1.0 D/AppDemo(

Is it possible to set xml layout as a view not from resources dynamically?

大城市里の小女人 提交于 2019-12-03 21:32:47
I want to set dynamic layout which is not present in resource like res or values.If it is present in my file-manager and i want to set that layout as a view layout.Is it possible to set dynamic layout to the views, without building app.I want to send the layout from the server and download the layout and set for the view without building and not from the resources.Is Butter knife used for this process or it's just for binding views to the variables. Try Proteus Proteus is meant to be a drop-in replacement for Android’s LayoutInflater ; but unlike the compiled XML layouts bundled in the APK,

How do I use obtainStyledAttributes(int []) with internal Themes of Android

橙三吉。 提交于 2019-12-03 18:35:50
问题 So I have looked around and found out that android.R.styleable is no longer part of the SDK even though it is still documented here. That wouldn't really be an issue if it was clearly documented what the alternative is. For example the AOSP Calendar App is still using the android.R.styleable // Get the dim amount from the theme TypedArray a = obtainStyledAttributes(com.android.internal.R.styleable.Theme); lp.dimAmount = a.getFloat(android.R.styleable.Theme_backgroundDimAmount, 0.5f); a