android-resources

Remove space between menu icon and title

江枫思渺然 提交于 2019-12-11 04:24:50
问题 In the image below, how can I remove the space between the icon and the title of the item in the menu? activity_main_drawer.xml: <?xml version="1.0" encoding="utf-8" ?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:icon="@drawable/ic_exit_to_app" android:id="@+id/logout" android:title="Logout" /> </menu> styles.xml: <?xml version="1.0" encoding="utf-8" ?> <resources> <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="colorPrimary">@color

Android Different Values Folder For Different Screen Sizes

强颜欢笑 提交于 2019-12-11 04:17:08
问题 i have an issue for my application. I want to define different view width and height dimensions or different text sizes for different screen sizes. I've defined different values folders for screen resolution as other question and Android documentation said. But i have a problem for this way. For example Samsung Galaxy S5 uses "values-sw320dp-xxhdpi" folder and Samsung Galaxy S3 Mini uses "values-sw320dp-hdpi" folder according to my tests. If i don't have sw-320dp-xxhdpi folder, i expected

Android: Difference between a System Resource and an Application Resource? [duplicate]

[亡魂溺海] 提交于 2019-12-11 04:00:06
问题 This question already has answers here : Useful Android system resources (4 answers) Closed 4 years ago . From Android documentation for the Resources class: public static Resources getSystem () Added in API level 1 Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc). What are system resources and application

How to obtain a theme by its reference id

折月煮酒 提交于 2019-12-11 03:54:53
问题 I need to extract a default value from a theme, BUT NOT from the current theme. I know that I can get get the attributes from the current theme like this: TypedValue typedValue = new TypedValue(); Theme currentTheme = context.getTheme(); currentTheme.resolveAttribute(android.R.attr.windowBackground, typedValue, true); // result is in: typedValue.data but I need something like: Theme darkTheme = getTheme(R.style.AppTheme.Dark); ... I only need to extract a single value, I do not want to change

Getting ResourceNotFoundException after device rebooted

最后都变了- 提交于 2019-12-11 02:35:36
问题 I am having Boot Completed Receiver in my application and after Reboot completed, inside my Boot Receiver I am starting an Activity. In that I am getting ResourceNotFoundException on setting layout. setContentView(R.layout.activity_home);//getting error of resource not found on this line I don't know the reason but its but obviously because it is not able to find the layout or R in my app. Anyone has any idea about this? Please kindly guide me to resolve this issue. EDIT - I found that if I

How to iterate over all strings, of all modules, and of all languages?

邮差的信 提交于 2019-12-11 01:48:07
问题 Background I know it's possible to iterate over all strings of a given R java file, using reflection as such (based on here): for (Field field : R.string.class.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers()) && !Modifier.isPrivate(field.getModifiers()) && field.getType().equals(int.class)) { try { int stringResId = field.getInt(null); Log.d("AppLog", field.getName() + ":" + getResources().getString(stringResId)); } catch (IllegalArgumentException | IllegalAccessException e)

Difference between setAdapter() and setDropDownViewResource() on Spinner

心已入冬 提交于 2019-12-10 22:22:43
问题 I looked at this question Difference between android.R.layout.simple_spinner_dropdown_item and android.R.layout.simple_spinner_item, but couldn't find an answer to my question. I can see that there is a difference between simple_spinner_item and simple_spinner_dropdown_item. But why do I need to set them both? Which part of Spinner layout is controlled by layout set in setAdapter() (simple_spinner_item ) and which one by layout set in setDropDownViewResource() (simple_spinner_dropdown_item) ?

Efficient way of creating Bitmap out of Drawable from res (BitmapFactory vs Type Casting)

自作多情 提交于 2019-12-10 20:33:23
问题 Which method is more efficient for creating Bitmap out of Drawable from resources? Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Vs Drawable myDrawable = getResources().getDrawable(R.drawable.icon_resource); Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap(); since API 22 above method is deprecated so use following Drawable myDrawable = ContextCompat.getDrawable(context, R.drawable.icon_resource) 回答1: You can take a look at the

Load from string.xml resources files depending on gender in android

与世无争的帅哥 提交于 2019-12-10 17:31:15
问题 I am working on application where themes and strings differs when user is male or female. I could control colors depending on user gender but now i can't solve problem of strings for example if user is a male, I will use <string name="welcome">Welcome boy</string> but if user female it will be <string name="welcome">Welcome girl</string> that is just for example.so how can i load the correct file from resources depending on gender value which is stored in variable ?? 回答1: There's no direct

Error inflating class ImageButton

喜夏-厌秋 提交于 2019-12-10 17:23:32
问题 I have an app which has fragment and image button on that. The problem is it's working on and above 5.0 but not below 5.0. The min sdk version is 17. Not getting what's wrong here. I am getting 2 exceptions. One is RuntimeException for image button . Second is ResourceNotFoundException for fab selector file. Log : 1st exception -- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view