Vector drawable shown as full circle - android

I have a following vector drawable:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeWidth="1"
android:pathData="M12.5,25 C19.4035594,25 25,19.4035594 25,12.5 C25,5.59644063 19.4035594,0 12.5,0
C5.59644063,0 0,5.59644063 0,12.5 C0,19.4035594 5.59644063,25 12.5,25 Z M12.5,24
C18.8512746,24 24,18.8512746 24,12.5 C24,6.14872538 18.8512746,1 12.5,1
C6.14872538,1 1,6.14872538 1,12.5 C1,18.8512746 6.14872538,24 12.5,24 Z M16,6
C17.6568542,6 19,7.34226429 19,8.99878564 L19,16.0012144 C19,17.6573979
17.6534829,19 16,19 C14.3431458,19 13,17.6577357 13,16.0012144 L13,8.99878564
C13,7.34260206 14.3465171,6 16,6 Z M14,16.0012144 C14,17.1052262 14.8952058,18
16,18 C17.1026267,18 18,17.1036857 18,16.0012144 L18,8.99878564 C18,7.89477378
17.1047942,7 16,7 C14.8973733,7 14,7.89631432 14,8.99878564 L14,16.0012144 Z
M8.33473905,12.5 C8.14415114,12.3451212 7.57820716,11.8273213
7.57820716,11.8273213 C6.80306599,11.0695455 6,10.0347728 6,9 C6,7 7,6 9,6 C11,6
12,7 12,9 C12,10.0347728 11.196934,11.0695455 10.4217928,11.8273213
C10.4217928,11.8273213 9.85584886,12.3451212 9.66526095,12.5
C9.85584886,12.6548788 10.4217928,13.1726787 10.4217928,13.1726787
C11.196934,13.9304545 12,14.9652272 12,16 C12,18 11,19 9,19 C7,19 6,18 6,16
C6,14.9652272 6.80306599,13.9304545 7.57820716,13.1726787 C7.57820716,13.1726787
8.14415114,12.6548788 8.33473905,12.5 Z M9.03460423,12 C10.1996214,11.0532638
11,9.74316 11,9 C11,7.55228475 10.4477153,7 9,7 C7.55228475,7 7,7.55228475 7,9
C7,9.74316 7.86958707,11.0532638 9.03460423,12 L8.96539577,13
C7.80037862,13.9467362 7,15.25684 7,16 C7,17.4477153 7.55228475,18 9,18
C10.4477153,18 11,17.4477153 11,16 C11,15.25684 10.1304129,13.9467362
8.96539577,13 L9.03460423,12 Z" />
</vector>
On preview tab in Android Studio it looks like this (and this is what is needed):
but when I set it programmatically to ImageView as its source, with the code:
imageMenuItem.setImageResource(R.drawable.keno);
it looks like this:
The xml code for ImageView is simple:
<ImageView
android:id="#+id/image_menu_item"
style="#style/UpperItemsImageLeftMenu"
app:srcCompat="#drawable/leftmenu_keno"
android:layout_width="#dimen/upper_item_image_dim_left_menu"
android:layout_height="#dimen/upper_item_image_dim_left_menu"
/>
The dark grey is the background, set elsewhere. Does anyone know how I can fix this?

Ok, so here is the solution.
Source of the problem
Problem is with this fill-rule in xml: android:fillType="evenOdd". Android doesn't support this parameter until Nougat version, so we must somehow avoid it. As #LewisMcGeary pointed out, there is an excellent explanation on this topis on : Marc Allison's blog. More about this fill-rule can be found on this link as suggested by #Duopixel.
My solution
I solved this problem by changing the software. I used this online tool as suggested by before mentioned blog post with following settings:
and then I saved it to xml with following content:
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:auto="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
tools:ignore="NewApi"
android:viewportWidth="25"
auto:viewportWidth="25"
android:viewportHeight="25"
auto:viewportHeight="25"
android:width="25dp"
auto:width="25dp"
android:height="25dp"
auto:height="25dp">
<path
android:pathData="M12.5 25C19.40356 25 25 19.40356 25 12.5C25 5.596441 19.40356 0 12.5 0C5.596441 0 0 5.596441 0 12.5C0 19.40356 5.596441 25 12.5 25M16 6C17.65685 6 19 7.342264 19 8.998786L19 16. 00121C19 17.6574 17.65348 19 16 19C14.34315 19 13 17.65774 13 16.00121L13 8.998786C13 7.342602 14.34652 6 16 6M14 16.00121C14 17.10523 14.89521 18 16 18C17.10263 18 18 17.10369 18 16.00121L18 8. 998786C18 7.894774 17.10479 7 16 7C14.89737 7 14 7.896314 14 8.998786L14 16.00121M8.334739 12.5C8.144151 12.34512 7.578207 11.82732 7.578207 11.82732C6.803066 11.06955 6 10.03477 6 9C6 7 7 6 9 6C11 6 12 7 12 9C12 10.03477 11.19693 11.06955 10.42179 11.82732C10.42179 11.82732 9.855849 12.34512 9.665261 12.5C9.855849 12.65488 10.42179 13.17268 10.42179 13.17268C11.19693 13.93046 12 14.96523 12 16C12 18 11 19 9 19C7 19 6 18 6 16C6 14.96523 6.803066 13.93046 7.578207 13.17268C7.578207 13.17268 8.144151 12.65488 8.334739 12.5M9.034604 12C10.19962 11.05326 11 9.74316 11 9C11 7.552285 10.44771 7 9 7C7.552285 7 7 7.552285 7 9C7 9.74316 7.869587 11.05326 9.034604 12M8.965396 13C7.800378 13.94674 7 15.25684 7 16C7 17.44772 7.552285 18 9 18C10.44771 18 11 17.44772 11 16C11 15.25684 10.13041 13 .94674 8.965396 13M12.5 24C6.148726 24 1 18.85127 1 12.5C1 6.148726 6.148726 1 12.5 1C18.85127 1 24 6.148726 24 12.5C24 18.85127 18.85127 24 12.5 24"
auto:pathData="M12.5 25C19.40356 25 25 19.40356 25 12.5C25 5.596441 19.40356 0 12.5 0C5.596441 0 0 5.596441 0 12.5C0 19.40356 5.596441 25 12.5 25M16 6C17.65685 6 19 7.342264 19 8.998786L19 16. 00121C19 17.6574 17.65348 19 16 19C14.34315 19 13 17.65774 13 16.00121L13 8.998786C13 7.342602 14.34652 6 16 6M14 16.00121C14 17.10523 14.89521 18 16 18C17.10263 18 18 17.10369 18 16.00121L18 8. 998786C18 7.894774 17.10479 7 16 7C14.89737 7 14 7.896314 14 8.998786L14 16.00121M8.334739 12.5C8.144151 12.34512 7.578207 11.82732 7.578207 11.82732C6.803066 11.06955 6 10.03477 6 9C6 7 7 6 9 6C11 6 12 7 12 9C12 10.03477 11.19693 11.06955 10.42179 11.82732C10.42179 11.82732 9.855849 12.34512 9.665261 12.5C9.855849 12.65488 10.42179 13.17268 10.42179 13.17268C11.19693 13.93046 12 14.96523 12 16C12 18 11 19 9 19C7 19 6 18 6 16C6 14.96523 6.803066 13.93046 7.578207 13.17268C7.578207 13.17268 8.144151 12.65488 8.334739 12.5M9.034604 12C10.19962 11.05326 11 9.74316 11 9C11 7.552285 10.44771 7 9 7C7.552285 7 7 7.552285 7 9C7 9.74316 7.869587 11.05326 9.034604 12M8.965396 13C7.800378 13.94674 7 15.25684 7 16C7 17.44772 7.552285 18 9 18C10.44771 18 11 17.44772 11 16C11 15.25684 10.13041 13 .94674 8.965396 13M12.5 24C6.148726 24 1 18.85127 1 12.5C1 6.148726 6.148726 1 12.5 1C18.85127 1 24 6.148726 24 12.5C24 18.85127 18.85127 24 12.5 24"
android:fillColor="#ffffff"
auto:fillColor="#ffffff" />
</vector>
I manually removed all auto:xxx tags and ended up with
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="NewApi"
android:viewportWidth="25"
android:viewportHeight="25"
android:width="25dp"
android:height="25dp"
>
<path
android:pathData="M12.5 25C19.40356 25 25 19.40356 25 12.5C25 5.596441 19.40356 0 12.5 0C5.596441 0 0 5.596441 0 12.5C0 19.40356 5.596441 25 12.5 25M16 6C17.65685 6 19 7.342264 19 8.998786L19 16.00121C19 17.6574 17.65348 19 16 19C14.34315 19 13 17.65774 13 16.00121L13 8.998786C13 7.342602 14.34652 6 16 6M14 16.00121C14 17.10523 14.89521 18 16 18C17.10263 18 18 17.10369 18 16.00121L18 8.998786C18 7.894774 17.10479 7 16 7C14.89737 7 14 7.896314 14 8.998786L14 16.00121M8.334739 12.5C8.144151 12.34512 7.578207 11.82732 7.578207 11.82732C6.803066 11.06955 6 10.03477 6 9C6 7 7 6 9 6C11 6 12 7 12 9C12 10.03477 11.19693 11.06955 10.42179 11.82732C10.42179 11.82732 9.855849 12.34512 9.665261 12.5C9.855849 12.65488 10.42179 13.17268 10.42179 13.17268C11.19693 13.93046 12 14.96523 12 16C12 18 11 19 9 19C7 19 6 18 6 16C6 14.96523 6.803066 13.93046 7.578207 13.17268C7.578207 13.17268 8.144151 12.65488 8.334739 12.5M9.034604 12C10.19962 11.05326 11 9.74316 11 9C11 7.552285 10.44771 7 9 7C7.552285 7 7 7.552285 7 9C7 9.74316 7.869587 11.05326 9.034604 12M8.965396 13C7.800378 13.94674 7 15.25684 7 16C7 17.44772 7.552285 18 9 18C10.44771 18 11 17.44772 11 16C11 15.25684 10.13041 13.94674 8.965396 13M12.5 24C6.148726 24 1 18.85127 1 12.5C1 6.148726 6.148726 1 12.5 1C18.85127 1 24 6.148726 24 12.5C24 18.85127 18.85127 24 12.5 24"
android:fillColor="#ffffff"
/>
</vector>
which is what I was looking for.

Related

Android Studio 4.1.0 could not update SDK (Error: Failed to read or create install properties file)

Problem:
Packages to install:
- Android SDK Platform 29 (platforms;android-29)
- Android Emulator (emulator)
- Android SDK Platform-Tools (platform-tools)
Preparing "Install Android SDK Platform 29 (revision: 5)".
Failed to read or create install properties file.
Preparing "Install Android Emulator (revision: 30.1.5)".
Failed to read or create install properties file.
Preparing "Install Android SDK Platform-Tools (revision: 30.0.5)".
Failed to read or create install properties file.
Failed packages:
- Android SDK Platform 29 (platforms;android-29)
- Android Emulator (emulator)
- Android SDK Platform-Tools (platform-tools)
Any idea how to fix it?
Background:
Check Network:
Clash is connected and I could visit google.com via Chrome on Mac
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
I read the question:
Android Studio fails to install update (error : Failed to read or create install properties file.)
On Mac, it seems that Android Studio already has the admin permission.
Android Studio permission
ls -la /Applications/Android\ Studio\ 4.1.0.app/Contents/MacOS
total 128
drwxrwxr-x# 3 gongzelong admin 96 Sep 24 04:21 .
drwxrwxr-x# 12 gongzelong admin 384 Sep 24 04:40 ..
-rwxr-xr-x# 1 gongzelong admin 65312 Sep 24 04:21 studio
sdkmanager permission:
ls -la $ANDROID_HOME/tools/bin
total 128
drwxr-xr-x 11 gongzelong staff 352 Jul 29 2018 .
drwxr-xr-x 15 gongzelong staff 480 Oct 26 21:18 ..
-rwxr-xr-x 1 gongzelong staff 6742 Jul 29 2018 apkanalyzer
-rwxr-xr-x 1 gongzelong staff 5253 Jul 29 2018 archquery
-rwxr-xr-x 1 gongzelong staff 6040 Jul 29 2018 avdmanager
-rwxr-xr-x 1 gongzelong staff 5250 Jul 29 2018 jobb
-rwxr-xr-x 1 gongzelong staff 6834 Jul 29 2018 lint
-rwxr-xr-x 1 gongzelong staff 3323 Jul 29 2018 monkeyrunner
-rwxr-xr-x 1 gongzelong staff 5613 Jul 29 2018 screenshot2
-rwxr-xr-x# 1 gongzelong staff 6047 Jul 29 2018 sdkmanager
-rwxr-xr-x 1 gongzelong staff 3076 Jul 29 2018 uiautomatorviewer
android sdk directory permission:
ls -la $ANDROID_HOME/
total 56
drwxr-xr-x# 26 gongzelong staff 832 Nov 3 01:51 .
drwx------# 104 gongzelong staff 3328 Nov 6 17:55 ..
-rw-r--r--# 1 gongzelong staff 18436 Oct 26 21:17 .DS_Store
drwxr-xr-x 2 gongzelong staff 64 Nov 4 01:47 .downloadIntermediates
-rw-r--r-- 1 gongzelong staff 16 Nov 6 17:46 .knownPackages
drwxr-xr-x 41 gongzelong staff 1312 Nov 4 23:08 .temp
-rw-r--r--# 1 gongzelong staff 1158 Aug 30 2018 SDK Readme.txt
drwxr-xr-x# 2 gongzelong staff 64 Aug 29 2016 add-ons
drwxr-xr-x# 34 gongzelong staff 1088 Nov 3 01:47 build-tools
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 cmake
drwxr-xr-x# 51 gongzelong staff 1632 Oct 24 2016 docs
drwxr-xr-x 17 root wheel 544 Nov 12 2019 emulator
drwxr-xr-x# 8 gongzelong staff 256 Jul 31 2018 extras
drwxr-xr-x# 3 gongzelong staff 96 Nov 7 2017 fonts
drwxr-xr-x# 9 gongzelong staff 288 Apr 21 2020 licenses
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 lldb
drwxr-xr-x 7 gongzelong staff 224 Nov 4 22:47 ndk
drwxr-xr-x# 20 gongzelong staff 640 Sep 29 2018 ndk-bundle
drwxr-xr-x# 5 gongzelong staff 160 Dec 15 2016 patcher
drwxr-xr-x 19 root wheel 608 Nov 12 2019 platform-tools
drwxr-xr-x# 16 gongzelong staff 512 Nov 3 01:47 platforms
drwxr-xr-x# 33 gongzelong staff 1056 Feb 17 2020 skins
drwxr-xr-x# 14 gongzelong staff 448 Nov 3 01:51 sources
drwxr-xr-x# 13 gongzelong staff 416 Apr 8 2019 system-images
drwxr-xr-x# 2 gongzelong staff 64 Feb 4 2018 temp
drwxr-xr-x 15 gongzelong staff 480 Oct 26 21:18 tools
platforms permission:
➜ bin ls -la $ANDROID_HOME/platforms
total 24
drwxr-xr-x# 16 gongzelong staff 512 Nov 3 01:47 .
drwxr-xr-x# 26 gongzelong staff 832 Nov 3 01:51 ..
-rw-r--r--# 1 gongzelong staff 10244 Dec 3 2018 .DS_Store
drwxr-xr-x# 13 gongzelong staff 416 Dec 3 2018 android-16
drwxr-xr-x# 12 gongzelong staff 384 Dec 16 2016 android-19
drwxr-xr-x# 12 gongzelong staff 384 Dec 18 2016 android-21
drwxr-xr-x# 12 gongzelong staff 384 Dec 8 2016 android-22
drwxr-xr-x# 14 gongzelong staff 448 Oct 19 2016 android-23
drwxr-xr-x# 15 gongzelong staff 480 Oct 19 2016 android-24
drwxr-xr-x# 14 gongzelong staff 448 Dec 16 2016 android-25
drwxr-xr-x# 14 gongzelong staff 448 Sep 28 2017 android-26
drwxr-xr-x 14 gongzelong staff 448 Jul 30 2018 android-27
drwxr-xr-x 14 gongzelong staff 448 Mar 29 2019 android-28
drwxr-xr-x 14 root staff 448 Nov 12 2019 android-29
drwxr-xr-x 15 gongzelong staff 480 Nov 3 01:47 android-30
drwxr-xr-x 14 gongzelong staff 448 Apr 24 2019 android-Q
$ANDROID_HOME/platform-tools
➜ bin ls -la $ANDROID_HOME/platform-tools
total 22584
drwxr-xr-x 19 root wheel 608 Nov 12 2019 .
drwxr-xr-x# 26 gongzelong staff 832 Nov 3 01:51 ..
-rw-r--r-- 1 root wheel 274638 Nov 12 2019 NOTICE.txt
-rwxr-xr-x 1 root wheel 3552684 Nov 12 2019 adb
drwxr-xr-x 4 root wheel 128 Nov 12 2019 api
-rwxr-xr-x 1 root wheel 60544 Nov 12 2019 dmtracedump
-rwxr-xr-x 1 root wheel 1581128 Nov 12 2019 e2fsdroid
-rwxr-xr-x 1 root wheel 309988 Nov 12 2019 etc1tool
-rwxr-xr-x 1 root wheel 1785900 Nov 12 2019 fastboot
-rwxr-xr-x 1 root wheel 17480 Nov 12 2019 hprof-conv
drwxr-xr-x 3 root wheel 96 Nov 12 2019 lib64
-rwxr-xr-x 1 root wheel 242532 Nov 12 2019 make_f2fs
-rwxr-xr-x 1 root wheel 829668 Nov 12 2019 mke2fs
-rwxr-xr-x 1 root wheel 1170 Nov 12 2019 mke2fs.conf
-rw-r--r-- 1 root wheel 17783 Nov 12 2019 package.xml
-rwxr-xr-x 1 root wheel 1532436 Nov 12 2019 sload_f2fs
-rw-r--r-- 1 root wheel 38 Nov 12 2019 source.properties
-rwxr-xr-x 1 root wheel 1315132 Nov 12 2019 sqlite3
drwxr-xr-x 6 root wheel 192 Nov 12 2019 systrace
I open the Android Studio icon in the Dock, does it mean that I run the AS as administrator?
I could download ndk and here is my current sdk:
Solution 1:
Use: sudo chown $USER: $ANDROID_HOME -R
My solution is setting folder permissions (and sub-folders using -R).
Root cause:
The permission of my Android SDK directory was set to write only by root so android-studio was unable to write any changes.
Detailed Process:
Take $ANDROID_HOME/platform-tools for example:
sudo chown $USER: $ANDROID_HOME/platform-tools
Before executing the command line:
bin ls -la $ANDROID_HOME/
total 56
drwxr-xr-x# 26 gongzelong staff 832 Nov 3 01:51 .
drwx------# 104 gongzelong staff 3328 Nov 6 17:55 ..
-rw-r--r--# 1 gongzelong staff 18436 Oct 26 21:17 .DS_Store
drwxr-xr-x 2 gongzelong staff 64 Nov 4 01:47 .downloadIntermediates
-rw-r--r-- 1 gongzelong staff 16 Nov 6 17:46 .knownPackages
drwxr-xr-x 41 gongzelong staff 1312 Nov 4 23:08 .temp
-rw-r--r--# 1 gongzelong staff 1158 Aug 30 2018 SDK Readme.txt
drwxr-xr-x# 2 gongzelong staff 64 Aug 29 2016 add-ons
drwxr-xr-x# 34 gongzelong staff 1088 Nov 3 01:47 build-tools
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 cmake
drwxr-xr-x# 51 gongzelong staff 1632 Oct 24 2016 docs
drwxr-xr-x 17 root wheel 544 Nov 12 2019 emulator
drwxr-xr-x# 8 gongzelong staff 256 Jul 31 2018 extras
drwxr-xr-x# 3 gongzelong staff 96 Nov 7 2017 fonts
drwxr-xr-x# 9 gongzelong staff 288 Apr 21 2020 licenses
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 lldb
drwxr-xr-x 7 gongzelong staff 224 Nov 4 22:47 ndk
drwxr-xr-x# 20 gongzelong staff 640 Sep 29 2018 ndk-bundle
drwxr-xr-x# 5 gongzelong staff 160 Dec 15 2016 patcher
**drwxr-xr-x 19 root wheel 608 Nov 12 2019 platform-tools**
drwxr-xr-x# 16 gongzelong staff 512 Nov 3 01:47 platforms
drwxr-xr-x# 33 gongzelong staff 1056 Feb 17 2020 skins
drwxr-xr-x# 14 gongzelong staff 448 Nov 3 01:51 sources
drwxr-xr-x# 13 gongzelong staff 416 Apr 8 2019 system-images
drwxr-xr-x# 2 gongzelong staff 64 Feb 4 2018 temp
drwxr-xr-x 15 gongzelong staff 480 Oct 26 21:18 tools
After executing the command line:
➜ bin ls -la $ANDROID_HOME/
total 56
drwxr-xr-x# 26 gongzelong staff 832 Nov 3 01:51 .
drwx------# 104 gongzelong staff 3328 Nov 6 17:55 ..
-rw-r--r--# 1 gongzelong staff 18436 Oct 26 21:17 .DS_Store
drwxr-xr-x 2 gongzelong staff 64 Nov 4 01:47 .downloadIntermediates
-rw-r--r-- 1 gongzelong staff 16 Nov 6 17:46 .knownPackages
drwxr-xr-x 41 gongzelong staff 1312 Nov 4 23:08 .temp
-rw-r--r--# 1 gongzelong staff 1158 Aug 30 2018 SDK Readme.txt
drwxr-xr-x# 2 gongzelong staff 64 Aug 29 2016 add-ons
drwxr-xr-x# 34 gongzelong staff 1088 Nov 3 01:47 build-tools
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 cmake
drwxr-xr-x# 51 gongzelong staff 1632 Oct 24 2016 docs
drwxr-xr-x 17 root wheel 544 Nov 12 2019 emulator
drwxr-xr-x# 8 gongzelong staff 256 Jul 31 2018 extras
drwxr-xr-x# 3 gongzelong staff 96 Nov 7 2017 fonts
drwxr-xr-x# 9 gongzelong staff 288 Apr 21 2020 licenses
drwxr-xr-x# 6 gongzelong staff 192 Apr 24 2019 lldb
drwxr-xr-x 7 gongzelong staff 224 Nov 4 22:47 ndk
drwxr-xr-x# 20 gongzelong staff 640 Sep 29 2018 ndk-bundle
drwxr-xr-x# 5 gongzelong staff 160 Dec 15 2016 patcher
**drwxr-xr-x 19 gongzelong wheel 608 Nov 12 2019 platform-tools**
drwxr-xr-x# 16 gongzelong staff 512 Nov 3 01:47 platforms
drwxr-xr-x# 33 gongzelong staff 1056 Feb 17 2020 skins
drwxr-xr-x# 14 gongzelong staff 448 Nov 3 01:51 sources
drwxr-xr-x# 13 gongzelong staff 416 Apr 8 2019 system-images
drwxr-xr-x# 2 gongzelong staff 64 Feb 4 2018 temp
drwxr-xr-x 15 gongzelong staff 480 Oct 26 21:18 tools
Then we do the update in SDK management:
before and after install sdk result screenshot
Solution 2:
Run Android Studio as administration.
sudo /Applications/Android\ Studio\ 4.1.0.app/Contents/MacOS/studio
It could also install the android sdk update successfully

Create shadow with blur, color and Y offset

I'm trying to create a shadow with these specific properties:
Blur , Y offset , color. (specified by the customer, using Zeplin to generate layout designs: link )
But I can't do this with "elevation" property only.
the only place I found these attributes at was by creating a 9-patch image using this website:
http://inloop.github.io/shadow4android
but the problem with it that it resizes my xml element(cardview,button...)
is there any other way to create shadows in Android?
You can convert png image to SVG.
Then you can convert that SVG to vector drawable in android.(you can use below mentioned online converter)
http://a-student.github.io/SvgToVectorDrawableConverter.Web/
relevant drawable for your example image is shown below. (it is a little bit different) you can do your own by following the above steps.
**But there are some limitations and please provide png which can be convertible to svg properly.
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="234"
android:viewportHeight="234"
android:width="292.5dp"
android:height="292.5dp">
<group
android:scaleX="0.1"
android:scaleY="-0.1"
android:translateY="234">
<path
android:pathData="M256 2252c-11 -9 -16 -12 -12 -5 4 7 -1 9 -14 6 -11 -3 -18 -8 -16 -12 2 -3 -7 -11 -20 -18 -13 -6 -22 -7 -18 -2 3 5 1 9 -4 9 -5 0 -12 -9 -15 -21 -4 -13 -10 -18 -18 -13 -8 4 -10 3 -5 -4 4 -8 0 -12 -11 -12 -11 0 -14 -3 -7 -8 7 -5 7 -14 -1 -29 -7 -13 -14 -20 -17 -18 -3 3 -8 -3 -11 -15 -3 -13 -1 -18 6 -13 7 3 4 -3 -7 -15 -15 -18 -16 -24 -6 -37 7 -8 9 -15 4 -15 -5 0 -9 -379 -9 -864 0 -492 4 -862 9 -859 5 3 4 -3 -2 -13 -8 -15 -7 -24 6 -38 9 -11 12 -16 5 -13 -7 5 -9 0 -6 -13 3 -12 8 -18 11 -15 3 2 10 -5 17 -18 8 -15 8 -24 1 -29 -7 -5 -4 -8 7 -8 11 0 15 -4 11 -12 -5 -7 -3 -8 5 -4 8 5 14 0 18 -13 3 -12 10 -21 15 -21 5 0 7 4 4 9 -4 5 5 4 18 -2 13 -7 22 -15 20 -18 -2 -4 5 -9 16 -12 13 -3 18 -1 13 6 -3 7 3 4 14 -6 14 -12 23 -15 28 -8 3 6 11 11 16 11 6 0 8 -3 6 -7 -3 -5 386 -8 863 -8 477 0 866 3 863 8 -2 4 0 7 6 7 5 0 13 -5 16 -11 5 -7 14 -4 28 8 11 10 17 13 14 6 -5 -7 0 -9 13 -6 11 3 18 8 16 12 -2 3 7 11 20 18 13 6 22 7 18 2 -3 -5 -1 -9 4 -9 5 0 12 9 15 21 4 13 10 18 18 13 8 -4 10 -3 5 4 -4 8 0 12 11 12 11 0 14 3 7 8 -7 5 -7 14 1 29 7 13 14 20 17 18 3 -3 8 3 11 15 3 13 1 18 -6 13 -7 -3 -4 2 5 13 13 14 14 23 6 38 -6 10 -7 16 -2 13 5 -3 9 366 9 858 0 475 -3 861 -7 858 -12 -7 -9 12 4 25 9 9 7 17 -8 33 -10 13 -14 19 -7 16 7 -5 9 0 6 13 -3 12 -8 18 -11 15 -3 -2 -10 5 -17 18 -8 15 -8 24 -1 29 7 5 4 8 -7 8 -11 0 -15 4 -11 12 5 7 3 8 -5 4 -8 -5 -14 0 -18 13 -3 12 -10 21 -15 21 -5 0 -7 -4 -4 -9 4 -5 -5 -4 -18 2 -13 7 -22 15 -20 18 2 4 -5 9 -16 12 -13 3 -18 1 -13 -6 3 -7 -3 -4 -14 6 -14 12 -23 15 -28 8 -3 -6 -11 -11 -16 -11 -6 0 -8 3 -6 8 3 4 -386 7 -863 7 -477 0 -866 -3 -863 -7 6 -12 -11 -10 -23 2 -7 7 -16 4 -28 -8zm1867 -106c15 -10 31 -30 35 -45 9 -34 9 -1828 0 -1862 -4 -15 -20 -35 -35 -45 -27 -18 -65 -19 -949 -19 -740 0 -926 3 -945 13 -57 30 -54 -16 -57 937 -2 484 0 904 3 934 8 62 38 97 88 104 18 2 437 4 932 3 862 -1 901 -2 928 -20z"
android:fillColor="#000000" />
<path
android:pathData="M2335 1165c0 -556 1 -784 2 -508 2 276 2 730 0 1010 -1 279 -2 54 -2 -502z"
android:fillColor="#000000" />
<path
android:pathData="M667 3C944 1 1396 1 1672 3 1949 4 1723 5 1170 5 617 5 391 4 667 3Z"
android:fillColor="#000000" />
</group>
</vector>

Random "Resource not found exception"

I have some AnimatedVectorDrawables that I've been working with no fail for a month or so. Today I created 2 more of these avds and one of them causes this "Resource$NotFoundException".
I am accessing it the exact same way as my other avds, it is in the same location as the other avds, and I created it the same way as the other avds. The only thing that is special about this one is a "startOffset" on one of the objectAnimators. I tried removing that line but the error persists. I have tried renaming the file, copy pasting the xml into another animation that I know is working, but these all cause a crash, which leads me to think it's something within the resource xml, but I can't spot anything.
Here is the stack trace:
android.content.res.Resources$NotFoundException: Drawable com.swerly.mypackage:drawable/test_avd with resource ID #0x7f0700ce
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/test_avd.xml from drawable resource ID #0x7f0700ce
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:768)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:600)
at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
at android.content.res.Resources.getDrawable(Resources.java:818)
at android.content.Context.getDrawable(Context.java:605)
at com.swerly.wifiheatmap.FabHelper.setAndPlay(FabHelper.java:74)
at com.swerly.wifiheatmap.FabHelper.setupFab(FabHelper.java:65)
at com.swerly.wifiheatmap.ActivityMain.backNavigation(ActivityMain.java:82)
at com.swerly.wifiheatmap.ActivityMain.onBackPressed(ActivityMain.java:51)
at android.app.Activity.onKeyUp(Activity.java:2965)
at android.view.KeyEvent.dispatch(KeyEvent.java:2712)
at android.app.Activity.dispatchKeyEvent(Activity.java:3257)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:537)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:336)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:351)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4714)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4586)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4468)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2435)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1998)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1989)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2412)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.content.res.Resources$NotFoundException: Drawable com.swerly.wifiheatmap:drawable/$test_avd__0 with resource ID #0x7f070026
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/$test_avd__0.x
Here is the code of the avd:
[EDIT: The issue is that the "pathData" fields weren't exported for some reason]
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:pathData=""
android:fillColor="#000000"/>
<path
android:name="path_1"
android:pathData=""
android:fillColor="#000000"/>
</group>
</vector>
</aapt:attr>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="pathData"
android:duration="500"
android:valueFrom="M 17 3 L 5 3 C 3.89 3 3 3.9 3 5 L 3 12 C 3 14.333 3 16.667 3 19 C 3 20.1 3.89 21 5 21 C 9.667 21 14.333 21 19 21 C 20.1 21 21 20.1 21 19 L 21 7 C 19.667 5.667 18.333 4.333 17 3 L 17 3 M 9 16 C 9 14.34 10.34 13 12 13 C 13.66 13 15 14.34 15 16 C 15 17.66 13.66 19 12 19 L 12 19 C 10.34 19 9 17.66 9 16 M 5 9 L 5 5 L 15 5 L 15 9 L 15 9 L 5 9"
android:valueTo="M 7 6 L 5.6 7.4 C 7.133 8.933 8.667 10.467 10.2 12 L 5.6 16.6 C 6.067 17.067 6.533 17.533 7 18 C 7.667 17.333 8.333 16.667 9 16 C 9.667 15.333 10.333 14.667 11 14 C 11.667 13.333 12.333 12.667 13 12 L 11 10 C 10.333 9.333 9.667 8.667 9 8 L 7 6 M 8 16 C 8 16 8 16 8 16 C 8 16 8 16 8 16 C 8 16 8 16 8 16 L 8 16 C 8 16 8 16 8 16 M 8 8 L 8 8 L 8 8 L 8 8 L 8 8 L 8 8"
android:valueType="pathType"
android:interpolator="#android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="path_1">
<aapt:attr name="android:animation">
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="pathData"
android:startOffset="175"
android:duration="325"
android:valueFrom="M 17 12 L 17 12 L 17 12 L 17 12 L 17 12 L 17 12 L 17 12"
android:valueTo="M 16.2 12 L 11.6 16.6 L 13 18 L 19 12 L 13 6 L 11.6 7.4 L 16.2 12"
android:valueType="pathType"
android:interpolator="#android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="group">
<aapt:attr name="android:animation">
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="rotation"
android:duration="100"
android:valueFrom="0"
android:valueTo="360"
android:valueType="floatType"
android:interpolator="#android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
I figured it out. Apparently the software I was using left the "pathData" fields empty on this export for some reason -_-

How to make border of LinearLayout in android as per following design

I have uses shape drawable to get rounded coreners but adding a semicircle in between seems tricky.
you can use vector asset studio to draw a custom shape and use it as background for your layout
https://developer.android.com/studio/write/vector-asset-studio.html
You can use Vector Drawable to achieve your end result. I used potrace to convert your image into svg format which is included at the bottom.
Use the Android Studio to create a vector drawable from this svg file.
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="271.000000pt" height="263.000000pt" viewBox="0 0 271.000000 263.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.13, written by Peter Selinger 2001-2015
</metadata>
<g transform="translate(0.000000,263.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M225 2546 c-40 -17 -84 -63 -101 -103 -12 -27 -14 -228 -14 -1140 0
-1093 0 -1107 20 -1149 12 -24 39 -54 62 -70 l41 -29 456 -3 c251 -2 471 0
489 3 23 4 32 11 32 25 0 11 7 20 15 20 8 0 19 16 25 39 14 54 79 124 142 152
74 33 191 33 265 0 61 -27 125 -92 142 -144 7 -21 17 -37 22 -37 5 0 9 -18 9
-40 0 -40 7 -49 25 -31 6 6 151 11 345 13 l335 3 36 24 c20 14 47 41 60 60
l24 35 3 1105 c1 608 0 1121 -3 1139 -8 42 -59 100 -110 123 -36 17 -73 19
-392 19 l-353 0 0 -35 c0 -24 -5 -35 -15 -35 -8 0 -24 -20 -36 -45 -25 -53
-74 -99 -138 -128 -36 -16 -66 -21 -136 -21 -79 -1 -97 3 -147 27 -90 44 -148
127 -148 211 l0 26 -462 0 c-361 -1 -470 -4 -493 -14z m920 -93 c13 -44 28
-67 70 -109 182 -177 521 -113 592 112 l17 54 335 0 c375 0 383 -1 428 -69
l23 -34 -2 -1113 -3 -1112 -25 -27 c-51 -55 -54 -55 -399 -55 l-319 0 -7 32
c-19 86 -84 160 -180 205 -52 24 -73 28 -150 28 -82 0 -97 -3 -157 -33 -84
-41 -143 -105 -164 -179 l-15 -53 -460 0 c-497 0 -487 -1 -539 55 l-25 27 -3
1111 c-2 1096 -2 1112 18 1145 11 18 34 41 52 52 32 19 52 20 465 20 l432 0
16 -57z"/>
</g>
</svg>

saveEventually cause stackoverflow crash

I'm using parse 1.5.1 sdk for Android and all just worked well till recent.
We did some table cleaning on our parse server database before going to production and ever since we are getting a stackoverflow crash every time we try to make 'saveEventually' to a specific table.
It looks like some kind of recursive happens on parse (by looking on the logs) android code.
Any clue what can fix it? (by the way, when using 'saveInBackground' it is working well)
Here is the stacktrace:
0
java.lang.StackOverflowError
1
at java.lang.ref.FinalizerReference.add(FinalizerReference.java:48)
2
at java.security.MessageDigestSpi.(MessageDigestSpi.java:30)
3
at java.security.MessageDigest.(MessageDigest.java:69)
4
at org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK.(OpenSSLMessageDigestJDK.java:53)
5
at org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK.(OpenSSLMessageDigestJDK.java:25)
6
at org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK$MD5.(OpenSSLMessageDigestJDK.java:119)
7
at java.lang.Class.newInstanceImpl(Native Method)
8
at java.lang.Class.newInstance(Class.java:1319)
9
at java.security.Provider$Service.newInstance(Provider.java:989)
10
at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:155)
11
at java.security.MessageDigest.getInstance(MessageDigest.java:91)
12
at com.parse.codec.digest.DigestUtils.getDigest(DigestUtils.java:88)
13
at com.parse.codec.digest.DigestUtils.getMd5Digest(DigestUtils.java:102)
14
at com.parse.codec.digest.DigestUtils.md5(DigestUtils.java:166)
15
at com.parse.codec.digest.DigestUtils.md5(DigestUtils.java:191)
16
at com.parse.codec.digest.DigestUtils.md5Hex(DigestUtils.java:227)
17
at com.parse.ParseJSONCacheItem.(ParseJSONCacheItem.java:16)
18
at com.parse.ParseObject.checkForChangesToMutableContainer(ParseObject.java:1074)
19
at com.parse.ParseObject.checkForChangesToMutableContainers(ParseObject.java:1096)
20
at com.parse.ParseObject.isDirty(ParseObject.java:997)
21
at com.parse.ParseUser.isDirty(ParseUser.java:95)
22
at com.parse.ParseObject.isDirty(ParseObject.java:992)
23
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
24
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1168)
25
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
26
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
27
at com.parse.ParseObject.isDirty(ParseObject.java:998)
28
at com.parse.ParseObject.isDirty(ParseObject.java:992)
29
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
30
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
31
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
32
at com.parse.ParseObject.isDirty(ParseObject.java:998)
33
at com.parse.ParseObject.isDirty(ParseObject.java:992)
34
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
35
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1168)
36
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
37
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
38
at com.parse.ParseObject.isDirty(ParseObject.java:998)
39
at com.parse.ParseObject.isDirty(ParseObject.java:992)
40
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
41
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
42
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
43
at com.parse.ParseObject.isDirty(ParseObject.java:998)
44
at com.parse.ParseObject.isDirty(ParseObject.java:992)
45
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
46
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1168)
47
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
48
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
49
at com.parse.ParseObject.isDirty(ParseObject.java:998)
50
at com.parse.ParseObject.isDirty(ParseObject.java:992)
...
...
...
540
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
541
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1168)
542
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
543
at com.parse.ParseObject.hasDirtyChildren(ParseObject.java:980)
544
at com.parse.ParseObject.isDirty(ParseObject.java:998)
545
at com.parse.ParseObject.isDirty(ParseObject.java:992)
546
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1178)
547
at com.parse.ParseObject.findUnsavedChildren(ParseObject.java:1174)
548
at com.parse.ParseObject.saveEventually(ParseObject.java:1559)
549
at com.sheep.ag.activities.GroupSettingsActivity.saveDataToParse(GroupSettingsActivity.java:1219)
550
at com.sheep.ag.activities.GroupSettingsActivity.onPause(GroupSettingsActivity.java:155)
551
at android.app.Activity.performPause(Activity.java:5304)
552
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1240)
553
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2889)
554
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2858)
555
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2836)
556
at android.app.ActivityThread.access$900(ActivityThread.java:140)
557
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1254)
558
at android.os.Handler.dispatchMessage(Handler.java:99)
559
at android.os.Looper.loop(Looper.java:137)
560
at android.app.ActivityThread.main(ActivityThread.java:4921)
561
at java.lang.reflect.Method.invokeNative(Native Method)
562
at java.lang.reflect.Method.invoke(Method.java:511)
563
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
564
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
565
at dalvik.system.NativeStart.main(Native Method)
I had the same problem when trying to assign a ParseUser to one of the fields of the ParseObject being saved.
When initializing the ParseObject I used "ParseObject.create()". It was fixed when I switched initialized the object doing "new ParseObject()" instead.

Categories

Resources