android-resources

How to prepare layout,drawable folders for 7“,10” android tablets for both landscape and portrait?

房东的猫 提交于 2019-11-28 19:13:16
问题 I have prepared my drawables for 7" tablets as (Nexus 7) drawable-large-hdpi-port layout-large-hdpi-port I am getting errors while doing this. I didnt understand where I am doing wrong. I want to prepare layouts for both landscape and portrait for both 7", 10" tablets 回答1: The recommended way is to use layout-swxxdp qualifier. If you need to differentiate landscape/portrait res/layout-sw600dp/ # For 7” tablets (600dp wide and bigger) res/layout-sw720dp/ # For 10” tablets (720dp wide and

Setting webview background image to a resource graphic in Android

江枫思渺然 提交于 2019-11-28 18:49:20
问题 I'm trying to set the background of a webview to a drawable image resource in Android. From the sdk it seems something like this would work but it doesn't. WebView web = (WebView) findViewById(R.id.webView); web.setBackgroundResource(R.drawable.backgroundmain); web.loadData(profile, "text/html", "UTF-8"); Any idea's? 回答1: As always you tend to figure these things out as soon as you ask the question. For the benefit of others, the layout that I'm using, LinearLayout, can take a background

Assets folder in Android Studio Unit Test

£可爱£侵袭症+ 提交于 2019-11-28 18:23:32
I have a Gradle project with the following structure: project/ src/ androidTest/ java/ main/ java/ res/ AndroidManifest.xml build.gradle Now I want to add a unit test which uses a resource (either "raw" or "asset"). I put my resource into project/androidTest/assets/test_file and access it with getContext().getResources().getAssets().open("test_file"); (in an AndroidTestCase ). However, this gives me a FileNotFoundException . How can I fix this? It looks like you're trying to create an instrumented unit test, since you want to create it in the androidTest folder. You can use one of these two

error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

六眼飞鱼酱① 提交于 2019-11-28 18:05:55
I added a Fragment to my Android Studio project using New > Fragment > Fragment (Blank) . As a result when I try to run, the project won't compile because it cannot resolve R.drawable.abc_ic_ab_back_mtrl_am_alpha in toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha); Any ideas how to solve this? It looks like I also lost access to android:buttonTint The name of the resource was changed in the 23.2.0 support library. Modify abc_ic_ab_back_mtrl_am_alpha to abc_ic_ab_back_material Edit: In 23.2.1 the name of the component was changed back to abc_ic_ab_back_mtrl_am_alpha Edit: In

Creating integer array of resource IDs

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 15:28:52
问题 I have some images in my res/drawable folder. Let's say img1.png , img2.png and img3.png . I am currently creating an integer array of these image IDs in Java like this int[] imgIds = {R.drawable.img1, R.drawable.img2, R.drawable.img3}; Instead, is it possible to create an integer array in one of res/values files (say strings.xml ) like this <integer-array name="img_id_arr"> <item>@drawable/img1</item> <item>@drawable/img2</item> <item>@drawable/img3</item> </integer-array> and then access it

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

假如想象 提交于 2019-11-28 15:25:13
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? Colt McAnlis This answer is summarized from Removing Unused Resources which explains how to use minifyEnabled and shrinkResources, which are covered in more depth at the Official

How to fix “No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version')”

情到浓时终转凉″ 提交于 2019-11-28 13:44:19
I am getting the following error when I build my Android App project in Visual studio 2015. No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version') These lines are located under: obj\Debug\android\manifest\AndroidManifest.xml There is 3 entires of it inside the AndroidManifest file . I have downloaded the google play service from the SDK Manager . Should I reference anything to my solution? I already has Xamarin.GooglePlayServices.Base, Xamarin.GooglePlayServices.Basement, Xamarin.GooglePlayServices.Maps Referenced. Thanks. Ironman you have

How to find resource id of a file located in /res/raw folder by its filename?

自作多情 提交于 2019-11-28 12:48:07
问题 I want to get the resource id of the file located in /res/raw folder by filename. I have tried the following 2 methods but both of them return resource id as 0 (zero). Method 1: String filename = "abc.txt"; int id = getResources().getIdentifier(filename, "raw", getPackageName()); Method 2: String filename = "abc.txt"; String fullyQualifiedName = getPackageName() + ":raw/" + filename; int id = getResources().getIdentifier(fullyQualifiedName, null, null); If this is not the correct way, then

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

ⅰ亾dé卋堺 提交于 2019-11-28 12:02:51
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. newbie 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 FirstActivity //to retrieve image using id set in xml. String imageString = "imageId" int resID =

How getResources().getString() works android

强颜欢笑 提交于 2019-11-28 11:33:56
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 then retrieve the value from getString() , something suggested in below links get-string-from-default