android-resources

How to rotate view by coordinate also in Android

本小妞迷上赌 提交于 2019-12-25 07:52:57
问题 first understand my question properly before voting, i have view that's like , <View android:id="@+id/View01" android:layout_width="280dp" android:layout_height="150dp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="50dp" android:layout_marginTop="83dp" android:background="#212121" android:rotation="-5" android:visibility="visible" /> and output is, you can see that when i use android:rotation="-5" , it rotate views(black box) but their

Hello World For Google Glass

≯℡__Kan透↙ 提交于 2019-12-25 07:09:45
问题 I'm trying to build a simple Hello World GDK program for Google Glass. I've looked up everywhere, but all the samples I could find used "Timeline Manager", which was removed by Google after XE 16. What I'm trying to do is to create a live card that shows texts (Hello world!) in the middle. I've tried to modify codes from HERE (HuskyHuskie's answer) and HERE (IsabelHM's answer) However, no matter what I did, no option or voice command appeared on the glass even though the console showed that

Why Android uses resources from the higher resource instead of a lower?

不想你离开。 提交于 2019-12-25 05:02:08
问题 There is an app which I want to adopt to xhdpi resolution phones. So I made resources for that resolution and all went fine regarding the xhdpi phones. I have a test mobile phone which is normal hdpi and the layout is now messed up (after I made fixes for xhdpi phones. The layout structure looks like this: /res/drawable-hdpi /res/drawable-normal-xhdpi /res/layout /res/layout-normal-xhdpi When I load the app on normal hdpi phone, I see that it uses layout from /res/layout-normal-xhdpi and

Android get list of string resources from special file

自作多情 提交于 2019-12-25 03:18:45
问题 For example, i have my_string.xml file with strings: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="my_string">My string</string> <string name="another_string">Another string</string> {...} </resources> Is it possible to get this strings to list/hashmap programmatically? Yeh, i know that i can take it by name or something like this. But i need to get it dynamically programmatically, for example, to HashMap<String, String> Or all string resources will merge together after

How does Android choose which small/normal/large resource folder?

房东的猫 提交于 2019-12-25 01:44:33
问题 I've a 7 inch tablet but Android select the normal/ resource folder, and it's wrong for me. I found that I can get the diagonal with some calculations: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); double x = Math.pow(dm.widthPixels / dm.xdpi, 2); double y = Math.pow(dm.heightPixels / dm.ydpi, 2); double screenInches = Math.sqrt(x + y); Log.d("debug", "Screen inches : " + screenInches); When choosing the resource folder, what Android does?

Load resources with variables?

徘徊边缘 提交于 2019-12-25 01:34:08
问题 I am loading XML file resource like this, getResources().getXml(R.xml.fiel1); Now, the scenario is that depending on factors there may be many xml files to choose from. How do I do that? In this case the filename is similar in the fact that all starts with file only ends with different numbers like file1, file2,file3 etc., So I can just form a String variable with the file name and add a suffix as per requirement to form a filename like file1 (file+1). Problem is I keep getting various errors

Issue with colors.xml in Android Studio 3.2.1

爱⌒轻易说出口 提交于 2019-12-24 19:29:35
问题 Following is the awkward and incomplete colors.xml I get while trying to create an Android project using Android Studio 3.2.1. The error I get is D:\AndroidStudioWorkspace\PlayCardz\app\src\main\res\values\colors.xml:7:19: Error: XML document structures must start and end within the same entity. Why is it happening? Update After manually changing colors.xml file to following I start getting the following error: Android resource compilation failed Output: D:\AndroidStudioWorkspace\GameCardz

Read raw file with unicode characters

混江龙づ霸主 提交于 2019-12-24 07:59:26
问题 I have a file in the /res/raw (R.raw.test) folder with the following content: This is a Tésêt I want to read it into a string. My current code is: public static String readRawTextFile(Context ctx, int resId) { InputStream inputStream = ctx.getResources().openRawResource(resId); InputStreamReader inputreader; try { inputreader = new InputStreamReader(inputStream, "UTF-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); return null; } BufferedReader buffreader = new

ResourceNotFoundException when running on phone but not on tablet

孤街浪徒 提交于 2019-12-24 00:55:24
问题 When I try to run my app on my Samsung Note II, I get a ResourceNotFoundException for this line setContentView(R.layout.activity_main); However, I don't get this exception when I run it on the emulator or my Samsung Note 10.1. Both are running Jellybean and my xml files are in folder called layout-land , and the XML file is in there. I tried cleaning my project and re-building, but it still doesn't work. Does anyone have an idea what's wrong? Let me know if I can provide any more information.

Android: How to load a vector drawable image into a webview?

不想你离开。 提交于 2019-12-24 00:08:15
问题 Sorry if this is a repeat but I searched diligently and didn't find this question asked yet... So back in ye olden days of Android, you could just add something like this to a WebView's source html: <img src='file:///android_res/drawable/my.png'/> And it would display my.png correctly in the WebView. But-- Android now supports (and prefers we use) these new-fangled vector drawables, and Android Studio's Vector Asset Studio makes it really easy to import them from SVG files or whatever. The