h6ah4i / android-materialshadowninepatch Goto Github PK
View Code? Open in Web Editor NEWProvides 9-patch based drop shadow for view elements. Works on API level 9 or later.
License: Apache License 2.0
Provides 9-patch based drop shadow for view elements. Works on API level 9 or later.
License: Apache License 2.0
I have a vertical linear layout with a couple other vertical linear layouts hosted inside of it. I'm trying to use this code to create a little bit of space between each inner item as well as add a shadow to them, but no matter what I try I can't get shadows to appear when I create an object dynamically
My code is as follows
container.removeAllViews();
for (LinearLayout aLayout : itemsToAdd) {
MaterialShadowContainerView msv = new MaterialShadowContainerView(getApplicationContext());
msv.setShadowElevation(dp(6));
msv.setShadowTranslationZ(dp(2));
msv.setForceUseCompatShadow(true);
ViewGroup.MarginLayoutParams p = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
p.setMargins(dp(6), dp(6), dp(6), dp(45));
msv.setLayoutParams(p);
msv.addView(aLayout);
container.addView(msv);
}
where container is a larger vertical linear layout that all of my smaller items are added to, and aLayout is each individual LinearLayout of an ArrayList collection. Right now I'm assuming there is something I've done wrong with the margins as no matter what I do I can't get them to show up at all. All I ever seem to get is one continuous block of white without a single shadow as shown below
Is there something wrong with the way I'm doing this, or is there an actual bug with this library?
supported border radius by this library? i can not find it
I add below line to dependencies and sync. It show's error.
compile 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:1.0.0'
error :
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
/Users/mehdi08/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a5e461f3cfccca112f65fb535223bc71/res/values/values.xml
Error:(252, 5) error: resource android:attr/fontVariationSettings not found.
Error:(252, 5) error: resource android:attr/ttcIndex not found.
/Users/mehdi08/08_Corp./Tapesh/Tapesh-Android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Error:(524) resource android:attr/fontVariationSettings not found.
Error:(524) resource android:attr/ttcIndex not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
Information:BUILD FAILED in 4s
Information:9 errors
Information:0 warnings
Information:See complete output in console
Can reduce overdraws when inner view has solid filled content.
related issue: #3
when i try to desing UI i get error for rendering page, please add some View.isInEditMode()
on yout class
Hi, how can i use style to set selector to set border radius for views?
From what I'm reading I think the answer is no, but I want to be sure. I have a SlidingPaneLayout
where the left pane has multiple colors in it, but the shadow uses the background color of the parent view and it looks terrible.
I've been playing around with the values in my app, and also looked at your source code, but I can't quite figure out what the difference is. I'm assuming shadowElevation is how "high" the shadow should be, e.g., what the elevation is of the material it's cast upon? While shadowTranslationZ is how "high" the item in the container is? I'm not sure – shadowElevation is not used in your sample!
Likewise for how much margin is required - you put 16dp for everything in the examples, but how can we calculate the minimum margin required for each shadow size?
Thank you so much for this library, I hope a short guide in the README would as helpful to others!
Help me fix this error please
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-tvdpi-v4/ms9_spot_shadow_z1.xml from drawable resource ID #0x7f0200e0 at android.content.res.Resources.loadDrawable(Resources.java:1953) at android.content.res.Resources.getDrawable(Resources.java:660) at com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.getNinePatchDrawableFromResource(MaterialShadowContainerView.java:311) at com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.updateShadowLevelCompat(MaterialShadowContainerView.java:346) at com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.updateShadowLevel(MaterialShadowContainerView.java:401) at com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.<init>(MaterialShadowCon
Hi,
This is great lib bro. is this lib support circle shapes and custom shapes? or just rectangle shapes?
ThnQ 👍
Is this by design?
I have something like this:
<MaterialShadowContainerView>
<LinearLayout>
<View android:background="#ff0000">
<View android:background="#00ff00">
</LinearLayout>
</MaterialShadowContainerView>
The shadow does not seem to draw if the LinearLayout does not have a background. If I set one, it works, but also means there's unnecessary overdraw.
Thanks for the very useful library, by the way!
Hello
I tried to add library repo
In gradle build I added:
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
}
android {
. . .
dependencies {
. . . .
compile 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:0.6.2'
}
}
After gradle update got following error:
Error:A problem occurred configuring project ':Android'.
> Artifact 'materialshadowninepatch.jar (com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:0.6.2)' not found.
Searched in the following locations:
https://jitpack.io/com/h6ah4i/android/materialshadowninepatch/materialshadowninepatch/0.6.2/materialshadowninepatch-0.6.2.jar
Also tried versions 0.6.1, 0.6.0 but I've experienced same issue
Maybe same as this issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.