android-drawable

Custom Android switch track 'animation'

我的未来我决定 提交于 2020-01-01 05:04:17
问题 I've created a basic custom Switch , as defined below. <Switch android:id="@+id/availSwitch" android:layout_width="wrap_content" android:switchMinWidth="110dp" android:layout_height="wrap_content" android:track="@drawable/switch_track" android:thumb="@drawable/thumb"/> The @drawable/thumb is a simple PNG which works fine. The @drawable/switch_track is defined below. @drawable/trackon and @drawable/trackoff are PNG's. <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item

Inset drawable not working as described in documentation

谁说我不能喝 提交于 2020-01-01 04:53:25
问题 As described on Android Developer site: A drawable defined in XML that insets another drawable by a specified distance. This is useful when a View needs a background that is smaller than the View's actual bounds. http://developer.android.com/guide/topics/resources/drawable-resource.html#Inset Instead of just moving the background and leaving the content in place in my case the inset is also moving the TextView. This is the layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns

android create pie dount with gradient

孤街醉人 提交于 2019-12-31 17:06:45
问题 Is there any way to create circle with gradient like this ? As far as i get is this: <shape android:innerRadiusRatio="3" android:thicknessRatio="10" android:shape="ring"> <gradient android:endColor="@color/cyan_dark" android:startColor="@color/red" android:type="radial" android:gradientRadius="340" android:centerX="50%" android:centerY="0" /> </shape> 回答1: XML <ProgressBar android:id="@+id/yourId" style="?android:attr/progressBarStyleHorizontal" android:layout_width="89dp" android:layout

Create a new color drawable

时光总嘲笑我的痴心妄想 提交于 2019-12-31 08:26:37
问题 I am trying to convert a hex value to an int so I can create a new color drawable. I'm not sure if this is possible, but according to the documentation, it should. It plainly asks for public ColorDrawable (int color) Added in API level 1 Creates a new ColorDrawable with the specified color. Parameters color The color to draw. So, my code isn't working because I'm getting an Invalid int: "FF6666" error. Any ideas? int decode = Integer.decode("FF6666"); ColorDrawable colorDrawable = new

Android checkboxes added by code don't have the right appearance?

白昼怎懂夜的黑 提交于 2019-12-31 03:49:09
问题 I've got a really basic app in which I'm trying to insert dynamic checkboxes, and I can get them to appear, but they're not showing with the correct styling. See below - Foo is in the LinearLayout by definition; Bar is being added programmatically. Foo is showing with a grey box for the check, Bar is showing with a white box. Link to image... Here's the code that's creating these: for (Integer i=0; i < arArray.length;i++) { CheckBox cb = new CheckBox(getApplicationContext()); cb.setText("Bar"

android loadIcon generates outOfMemoryError

为君一笑 提交于 2019-12-30 13:08:07
问题 I just have a little ListView containing all installed apps and their icons but if there are too much Apps installed i run into outOfMemoryErrors while doing Drawable app_icon = applicationInfoList.get(i).loadIcon(context.getPackageManager())); that for every ListEntry (this line is written in my ListAdapter ) no problem so far, i understand why i ran into this error (too much icons loaded, too few vm heap) but i had a look at the source code of androids ManageApplications Activity in the

How should we use the mipmap folders added with android 4.4?

时光毁灭记忆、已成空白 提交于 2019-12-30 06:56:01
问题 I recently installed one more Android SDK to Android Studio, the SDK version 4.4 (API level 19), and after using it with my project, it added a set of mipmap folders in the project's res folder ( res/mipmap ). I neither understand why, or how to use them. I read another question about it here on SO. The answer to it said that: The mipmap folders are for placing your app icons in only. Any other drawable assets you use should be placed in the relevant drawable folders as before. According to

How should we use the mipmap folders added with android 4.4?

南笙酒味 提交于 2019-12-30 06:55:03
问题 I recently installed one more Android SDK to Android Studio, the SDK version 4.4 (API level 19), and after using it with my project, it added a set of mipmap folders in the project's res folder ( res/mipmap ). I neither understand why, or how to use them. I read another question about it here on SO. The answer to it said that: The mipmap folders are for placing your app icons in only. Any other drawable assets you use should be placed in the relevant drawable folders as before. According to

Bitmap and outOfMemory in android

那年仲夏 提交于 2019-12-29 02:11:31
问题 I have problem with out of memory with my bitmap. This is code: Uri bitmapPictureUri = intent.getParcelableExtra(TaskActivity.PHOTO); Bitmap bitmap = null; try { bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), bitmapPictureUri); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int nh = (int) (bitmap.getHeight() * (512.0 / bitmap.getWidth()));

Add ripple effect to my button with button background color?

一世执手 提交于 2019-12-27 16:32:23
问题 I created a button and I want to add ripple effect to that button! I created a button bg XML file: (bg_btn.xml) <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFFFF" android:endColor="#00FF00" android:angle="270" /> <corners android:radius="3dp" /> <stroke android:width="5px" android:color="#000000" /> </shape> And this is my ripple effect file: (ripple_bg.xml) <ripple xmlns:android="http://schemas.android.com/apk