android-resources

Android splash screen: how to make it centered?

别等时光非礼了梦想. 提交于 2019-12-13 05:02:20
问题 I use a theme-based solution as it described here, for example, to show a splash screen in my application. Here is my background_launch.xml: <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/launch_image" android:tileMode="disabled" /> When I have launch_image as png everything is OK. But the app crashes if I use @drawable/layerlist instead of @drawable/launch_image . layerlist.xml is: <layer-list xmlns:android="http://schemas.android.com/apk/res

Crash by org.xmlpull.v1.XmlPullParserException from android.graphics.drawable.Drawable.createFromXmlInner

一曲冷凌霜 提交于 2019-12-13 03:45:26
问题 An app has the following crash that appears to happen only with Samsung Galaxy Android 4.4 devices. android.content.res.Resources$NotFoundException: at android.content.res.Resources.loadDrawable (Resources.java:3422) at android.content.res.Resources.getDrawable (Resources.java:1909) at android.support.v4.content.ContextCompat.getDrawable (ContextCompat.java:465) at android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:203) at android.support.v7.widget

App crashing when fetching from string ressources [duplicate]

房东的猫 提交于 2019-12-12 21:37:13
问题 This question already has answers here : How to get String Array from arrays.xml file (3 answers) Closed 5 years ago . I have a string array in the string.xml ressources; <string-array name="errors_signup"> <item>Successful sign up</item> <item>Invalid username!\n(more than 4 characters have to be used)</item> <item>Username already taken!\n(Change it)</item> <item>Invalid e-mail address!</item> <item>E-mail already used!\n(Choose another one)</item> <item>Invalid password\n(more than 4

Why does saving a loaded Bitmap increase it's size?

一笑奈何 提交于 2019-12-12 19:39:13
问题 I load a png file from the sdcard. I alter it in someway and then save it again. I have noticed that the saved file is much larger than the original. At first I thought it was because of modifying the file. Then I tested with the code below and still happens. I just load a png file and then save it with another name. The Original file is 32Kb and the Saved file is 300Kb . Any ideas? try { Bitmap bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/Original.png");

How to reference an XML file in Android Javadoc? [duplicate]

ε祈祈猫儿з 提交于 2019-12-12 10:43:31
问题 This question already has answers here : Reference resources in javadoc (3 answers) Closed 2 years ago . Is there a way to use JavaDoc links to reference Android XML files in res folder. Something like {@link res/values/custom_strings.xml} . 回答1: {@link com.yourApp.R.layout#layoutName} 回答2: Someone else answered this question in another topic. Here's the link: https://stackoverflow.com/a/24814578/7262915 Hope this helps you! 来源: https://stackoverflow.com/questions/41433645/how-to-reference-an

Android - ConstraintLayout percentage using dimens

Deadly 提交于 2019-12-12 10:36:23
问题 There is a question How to make ConstraintLayout work with percentage values? and its answers show how to use the percentages: <android.support.constraint.Guideline android:id="@+id/guideline" android:layout_width="1dp" android:layout_height="wrap_content" android:orientation="vertical" app:layout_constraintGuide_percent="0.5"/> But if you don't want to hardcode the percentage but use a dimen resource it does not work. <!-- inside the layout --> <android.support.constraint.Guideline android

How to use getString() on static String before onCreate()?

百般思念 提交于 2019-12-12 07:06:32
问题 I am trying to use getString() to get an String from resources to assign it to an String array before my activity is created: private static final String[] MenuNames = { Resources.getSystem().getString(R.string.LCMeterMenu), Resources.getSystem().getString(R.string.FrecMenu), Resources.getSystem().getString(R.string.LogicAnalyzerMenu), "Prueba con achartengine", Resources.getSystem().getString(R.string.BrazoMenu) }; When I use Resources.getSystem().getString(R.string.LCMeterMenu) , Eclipse

android - how to get path of mp3 stored in raw folder

耗尽温柔 提交于 2019-12-12 06:38:39
问题 After searching for solution, I have found from this link that it is possible to retrieve path like: Using Resource Id Syntax : android.resource://[package]/[resource_id] Example : Uri.parse("android.resource://com.my.package/" + R.raw.mp3filename); Which is exactly what I want. Problem is that, I'm using lolipop, and it does not work. When the package/resource is parsed, path from Uri.parse will be null. Is there other way around to write this, since in my Song class, I have only access to

Can't get string resource from R.string.*

瘦欲@ 提交于 2019-12-12 06:24:25
问题 I have a SQlite table with two columns _id and name . For internationalization purpose I store the name like R.string.today Now I want to get string resource associated with R.string.today : String column = myCursor.getString(myCursor.getColumnIndex(MainDb.NAME)); int resId = getApplicationContext().getResources().getIdentifier(column, "strings", getApplicationContext().getPackageName()); String buttonText; if (resId != 0) { buttonText = getApplicationContext().getString(resId); } else {

How to get the id of a string resource associated with a TextView?

♀尐吖头ヾ 提交于 2019-12-12 05:12:30
问题 I can access the TextView instance, get it's resource ID and get it's resource name via getResources().getResourceEntryName() , but I can't seem to find a way to get the id of the string associated with it. How can I dynamically get the id of the string resource associated with a TextView ? 回答1: You can't. A TextView doesn't store the id of the String resources if you call setText(int resid) . All this overloaded method does is get the String from the resources and call the setText