android-drawable

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

Android getDrawable() Deprecated / How To use Android getDrawable()

南笙酒味 提交于 2019-12-23 22:16:04
问题 Can anyone tell me the right way of using getDrawable() , I recall last time I used it was just fine with one parameter, but now I am getting this method is deprecated error, anyone? Bellow is the snippet I am trying to use private void toggleUi() { ImageView imageView = (ImageView) findViewById(R.id.silent_icon); Drawable silentImage; if(silent) { silentImage = getResources().getDrawable(R.drawable.silent_on); } else { silentImage = getResources().getDrawable(R.drawable.silent_off); }

LayerDrawable.setLayerInset() not working on android 2.3

不问归期 提交于 2019-12-23 19:19:08
问题 Following sample working for android 4.1 but for android 2.3 left and right inset are not changed. What is the reason for this behavior? public class MyFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.badges_fragment_layout, container, false); view.setBackgroundDrawable(getCustomDrawable()); return view; } private Drawable getCustomDrawable() { LayerDrawable

Android : automate SVG import

天大地大妈咪最大 提交于 2019-12-23 19:19:08
问题 We have a legacy Android project using drawables in the respective drawable folders for mdpi, hdpi, etc., We are planning to remove the PNG files and transition to SVG. The SVG Import UI described here creates the drawables xml from the svg. Is there a way to run this tool from command line so that we can automate the conversion from SVG to Android Drawable.xml format. We have a lot of files, so doing it manually is tedious. (Alternatively, if this is not possible, I will be writing a script

How to get path from image on drawable folder and set as image view, Bitmap?

半腔热情 提交于 2019-12-23 18:37:19
问题 I already have some pictures on my drawable folder from android project. I create some objects (Agents) and then I need to set the imageView with this picture I saved on database. So, I am saving the picture as String photoPath : Uri path1 = Uri.parse("android.resource://"+BuildConfig.APPLICATION_ID+"/" + R.drawable.agent1); String photoAg1 = path1.getPath(); ag1.setPhotoPath(photoAg1); (I have already tried path1.toString.) Ok, no problems until there. This object is shown at a listView with

Drawables pulled from wrong resource folder on rotation

浪尽此生 提交于 2019-12-23 15:15:35
问题 Pulling my hair out here. So I'm working with an application that has several types of drawables, and I have them in a structure like so: res/ //Portrait resources drawable-mdpi/ drawable-hdpi/ drawable-xhdpi/ //Landscape resources drawable-land-mdpi/ drawable-land-hdpi/ drawable-land-xhdpi/ EDIT I've also tried even putting the portrait-specific drawables under drawable-port-mdpi , etc. with the same result. And I have a custom View which I'm using to pull in drawables at runtime. Here's a

Button's background drawable (shape) won't show up unless app API is 20+ (Android L)

落花浮王杯 提交于 2019-12-23 13:28:08
问题 In my Android app, I'm trying to set a simple ring shape as background drawable for my Buttons. But as much as I try, the XML preview ignores the background drawable unless the API level is set to 20 (Android L) What's going on? I'm sure people used to set shapes for buttons before L. Code for my XML shape for button_ring.xml located in /drawables folder <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" > <solid

Detect keyboard in android

ぐ巨炮叔叔 提交于 2019-12-23 05:15:38
问题 I have an android application which contain list of installed applications and launch them on item click.In my application I used Intent.ACTION_CLOSE_SYSTEM_DIALOG broadcast for closing system dialogs such as Task Manager(Recent Apps dialog),Power Option dialog,Low battery dialog etc....But this hides keyboard in some devices.I want to make sure that the user could not interact with recent apps dialog from my applications.How can i close system dialogs except keyboard?How can i check whether

Android 4.2 9-patch background drawn differently than older OS versions

十年热恋 提交于 2019-12-23 03:21:41
问题 I have a Nexus 7 with Android 4.2.1 and I noticed in my app the background image I am using for some linear layouts is drawn incorrectly. With other devices with older versions of the Android OS the 9-patch background is drawn correctly but with this device the border line is stretched when it should not be stretched. Correct (Evo 4G v2.3.5): http://i.imgur.com/WDTNr.png Incorrect (N7 v4.2.1): http://i.imgur.com/HntMY.png Any idea what is causing this? If not, is there any other way to get

Android 4.2 9-patch background drawn differently than older OS versions

帅比萌擦擦* 提交于 2019-12-23 03:21:30
问题 I have a Nexus 7 with Android 4.2.1 and I noticed in my app the background image I am using for some linear layouts is drawn incorrectly. With other devices with older versions of the Android OS the 9-patch background is drawn correctly but with this device the border line is stretched when it should not be stretched. Correct (Evo 4G v2.3.5): http://i.imgur.com/WDTNr.png Incorrect (N7 v4.2.1): http://i.imgur.com/HntMY.png Any idea what is causing this? If not, is there any other way to get