android-resources

Density-specific layouts vs. size-specific layouts in Android

烂漫一生 提交于 2019-12-08 15:50:28
问题 For quite a long time, I have been declaring resource folders for 4 different densities: drawable-ldpi drawable-mdpi drawable-hdpi drawable-xhdpi In the layout's XML, I have been using fixed widths (while still density-independent) such as 128dp for those graphics. However, when more and more large-screen phones, and especially tablets, were introduced, that approach did not work anymore. Although you provide density-independent resources this way, the layout will not look good on large

Triangular Bullet in Android TextView for Pre-Lollipop devices

牧云@^-^@ 提交于 2019-12-08 13:25:32
I Tried character encoding "& #8227;"---> and java strings "\u2023" and also tried pasting directly the Triangular Bullet "‣". I tried both 1) Directly specifying in android:text attribute and 2) Extracting from resource. All the methods specified above working fine with the Lollipop but none of them working in 4.2.2 and previous android versions. Instead of the Bullet it is showing some rectangular box. any ideas how to solve it ?? For displaying ▶, use \u25b6 (for displaying ▷, use \u25b7 ). Tested on a 2.2 (Froyo) emulator: works . This is a very useful resource: http://unicode-table.com/en

Is there a way to extract a string with an automatically generated resource name for a java file in Android Studio?

无人久伴 提交于 2019-12-08 07:10:40
问题 In Android Studio, Alt + Enter > "Extract String Resource" in a java file will open the following window: Please note that the Resource name field is blank. However, the window will be like the following for a layout XML file: Please note the Resource name field is filled automatically. How can the Resource name field be filled with an automatically generated name for java files too? It thought the Resource name was filled automatically for all types of files before the current version of

Using colors defined in base module from feature module fails after rebuilding the Android Instant App

萝らか妹 提交于 2019-12-08 05:20:44
问题 I have a base module and a feature module called query module in my Instant App project. My QueryActivity inside query module uses colors that are in base module. QueryActivity.kt: @ColorInt val textColor: Int = when (resultCode) { FetchAddressIntentService.RESULT_SUCCESS -> android.R.color.white FetchAddressIntentService.RESULT_FAILURE -> R.color.accent // this color is inside the base module else -> R.color.accent // this color is inside the base module } If I try to run the project, it

Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 04:55:16
问题 Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods Explanation: Right now this program accesses a file from a file manager that takes the selected files path and sets it to the 'mFilename' EditText field. The show PDF button listener below shows the String 'pdffilename' gets assigned the String contained in the 'mFilename' EditText field. The PdfViewerActivity is started and the String 'pdffilename' is passed as an Extra. In the onCreate() the intent

Android Studio can't find color reference within the same resource file

纵饮孤独 提交于 2019-12-08 04:51:00
问题 Here's the content of my resource file \res\values\colors.xml : <?xml version="1.0" encoding="utf-8"?> <resources> <color name="themeGray">#ff8A9199</color> <color name="themeLightGray">#ffeaeaea</color> <color name="themeDarkGray">#ff3f434b</color> <color name="themeRed">#ffCC292B</color> <color name="themeBlue">#ff002E63</color> <color name="themeWhite">#ffffffff</color> <color name="buttonNormal">@color/themeGray</color> <color name="buttonPressed">@color/themeBlue</color> </resources> The

ImageButton background swiching on it's own? Drawables gone wild?

南笙酒味 提交于 2019-12-08 04:28:27
问题 I having an issue where the ImageButton background is being drawn with a different drawable from one of my resources. I'm setting the background to be transparent but on some cases it's picking up one of my drawables called bottom_shadow.9.png. Why why!? It's freaking weird... I've seen this issue before... Some of my app users have complained seeing this issue and now I'm determined to figure this out! Take a look below what I currently have. Any tips or ideas would help. The color value I

Triangular Bullet in Android TextView for Pre-Lollipop devices

强颜欢笑 提交于 2019-12-08 03:59:50
问题 I Tried character encoding "& #8227;"---> and java strings "\u2023" and also tried pasting directly the Triangular Bullet "‣". I tried both 1) Directly specifying in android:text attribute and 2) Extracting from resource. All the methods specified above working fine with the Lollipop but none of them working in 4.2.2 and previous android versions. Instead of the Bullet it is showing some rectangular box. any ideas how to solve it ?? 回答1: For displaying ▶, use \u25b6 (for displaying ▷, use

Retrieve a color from values/colors.xml using a variable in name (R.color.name + variable)

二次信任 提交于 2019-12-08 01:34:26
问题 I have a list of colors in my colors.xml that all have names in the format tColor1, tColor2, tColor3, etc. and I want to retrieve them in a for-to-do loop using the looping integer as part of the name. So I have for (int i = 0; i < numTrails; i++) { newColors[i] = R.color.tColor + i; } Now I understand that I can't use the R class like that, but what other method can I use to get the colors? 回答1: You can do something like this, assuming your newColors Array is an int Array with the resource

Get Uri from file in either assets or res/raw

与世无争的帅哥 提交于 2019-12-08 00:46:18
问题 I have tried to get this working and I have looked at many different resources online (as you can see from all of the comments I have made). I want to access a .pdf file that is either located in assets or res; It does not matter to which one so the easiest way will do. I have the method below that will get the actual file and will call another method(under the first method below) with the Uri in the parameters. Thank you very much for your help and I will be standing by to answer questions