android-resources

How do I remove unused resources from third-party libraries I’ve included on Android?

喜欢而已 提交于 2019-11-27 09:12:26
问题 The third-party libraries that I link into my app often include resource files that aren’t being used by my application, and as such, end up bloating my APK. For example, including the Google Play services library, but not using the login button functionality; all those image and layout resources end up in my final build. Since these resources are included in a compiled library, how can I remove them from my build? 回答1: This answer is summarized from Removing Unused Resources which explains

What is the concept behind R.java?

牧云@^-^@ 提交于 2019-11-27 08:33:52
In android R.java is used to provide access to resources defined in XML files. To access the resource we need to invoke findViewById() method passing in the id of the resource to be fetched. This is similar to Spring where beans are defined in a XML context and are fetched by using application context. context.getBean("beanId") This provides loose coupling since the beans are defined externally and could be changed without making modifications to the code. This has me confused. Though what Android does looks similar to spring, what advantage does it offer? What is the point of having an

How can I add a sub folder to the raw folder in my Android app? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-27 07:35:39
问题 This question already has an answer here: Can the Android Layout folder contain subfolders? 18 answers Of course I can right click the raw folder and add new folder but when I export the project, the APK file does not contain the new sub folder. 回答1: You can't. The folders in /res/ have a predefined structure, and you can't add subfolders. However, seeing as this is the raw folder, you may want to look into using the assets folder, in which sub folders are supported. Keep in mind thought that

Android, reference things in R.drawable. using variables?

女生的网名这么多〃 提交于 2019-11-27 06:42:09
问题 say I want to dynamically load an image file in R.drawable.* based on the value of a string Is there a way to do this? It seems like I need to statically refer to anything in R. 回答1: Have you declared the id for the image in XML file? If you did, you can use the following method: Let's say you have picture.png in your res/drawable folder. In your activity, you can set your image resource in the main.xml file <ImageView android:id="@+id/imageId" android:src="@drawable/picture"></ImageView> In

Android: html in strings.xml

戏子无情 提交于 2019-11-27 06:35:13
I would like display for example this html code: <body> <p><b>Hello World</b></p> <p>This is a test of the URL <a href="http://www.example.com"> Example</a></p> <p><b>This text is bold</b></p> <p><em>This text is emphasized</em></p> <p><code>This is computer output</code></p> <p>This is<sub> subscript</sub> and <sup>superscript</sup></p> </body> I want to display it on a Dialog by declaring html in resources strings.xml . How can I do it? Mario Kutlev The best way to add html source code in strings.xml is to use <![CDATA[html source code]]> . Here is an example: <string name="html"><![CDATA[<p

How getResources().getString() works android

我的梦境 提交于 2019-11-27 06:23:09
问题 For e.g there is app which provides multi-language support, in my activity/UI, I call getResources().getString(R.string.hello) which exist in strings.xml,such that values\strings.xml values-ru\strings.xml Now when calling getResources().getString(R.string.hello) and need to access string based on system locale, so will one get strings from values\strings.xml OR values-ru\strings.xml ? OR does one need to change my app locale based on system locale (keep app locale same as system locale) and

Value equals to match_parent or fill_parent in dimens.xml?

房东的猫 提交于 2019-11-27 05:29:23
问题 Based on here on XML Attributes section I specify following in my dimens.xml : <dimen name="match_parent">-1dp</dimen> <dimen name="main_left_menu_user_account_width">@dimen/match_parent</dimen> <dimen name="main_left_menu_user_account_height">@dimen/match_parent</dimen> Then I use the both dimensions in my layout: <ImageView android:id="@+id/userAccountImage" android:background="@drawable/user_account" android:layout_width="@dimen/main_left_menu_user_account_width" android:layout_height="

Android method with default (package) visibility overriding (shouldn't work, but does - why?)

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:32:24
问题 I've been playing around with SVG support in Android and came up with this library which claims that it supports SVG just as it they were native. Since I took great pains in discovering that this is not really possible, I went to see how this dude actually managed it. So I came upon his Resources derivative in which he declares a method ( loadDrawable ) that has default visibility in base Resources class. The funny thing is, normally lint would just report that you can't write this method

Android Studio exports strings from support library to APK

你说的曾经没有我的故事 提交于 2019-11-27 04:19:08
问题 Recently i switched from Eclipse to Android Studio. I have a project with multiple module dependencies. One dependency is the support library appcompat, included like this: dependencies { compile "com.android.support:appcompat-v7:19+" } In the Android docs i found out that this library needs to be imported with resources, which seem to work OK. I use the library in my project without problems. The problem is, when i build an APK and run aapt, the outpus says: locales: '--_--' 'de' 'nl' 'pl'

How to return to default style on EditText if I apply a background?

▼魔方 西西 提交于 2019-11-27 03:43:49
问题 I just encountered with a problem that I don't know how to solve. It looks silly but I cannot find a way to fix it. I have a form in android with several EditText and when you submit the form it checks those EditText and if they have wrong data I change the EditText to red border (applying a ninepatch image). myEditText.setBackgroundResource(R.drawable.edittext_red); The problem is, I want to restore android's default style when the user change the EditText, but I don't know how to do it. if