Making of shadowfrom the CommonsWare Community archives
At January 20, 2020, 4:49pm, Pvr asked:
1 ) I want to know how to add shadow to a layout
and able to keep it in certain position from the layout .
2 ) I also want to make this shadow Enable and Disable through "Java " at certain positions (Eg : For 10 images , i can be able to place shadow Enable/Disable wherever is needed ).
At January 20, 2020, 5:36pm, mmurphy replied:
Usually, that is handled by the
android:elevation attribute. This takes a dimension (value or resource). The higher the dimension, the bigger the drop shadow will appear.
I do not know what this means, sorry.
You can call
setElevation() on a
View to change its elevation. Setting it to
0 will remove the drop shadow.
At January 20, 2020, 6:19pm, Pvr replied:
- able to keep it in certain position from the layout -> Distance(coordinates) between shadow and image , if possible
At January 20, 2020, 6:33pm, mmurphy replied:
I still am uncertain what you mean.
If you mean how big the shadow is (how far it extends from the view), if you use elevation, larger elevation values give you larger shadows.
If that is insufficient, you will need to fake your own shadow:
- Put the widget that needs the shadow in a
- Create some drawable that will render the shadow
- Apply that drawable to the
FrameLayoutas its background
endpadding in the
FrameLayoutto allow the background to appear
At January 20, 2020, 6:52pm, Pvr replied:
I want to keep shadow like shown in pic
At January 20, 2020, 7:16pm, mmurphy replied:
At this point, I cannot provide you with further advice. Either use
elevation for Android’s standard drop shadow option, or create your own (e.g., using the
FrameLayout as I mentioned previously).
At January 24, 2020, 5:48pm, Pvr replied:
I want to know that When i try to acces dimen from Java (var=context.getResources().getDimensionPixelSize(R.dimen.value)
I got an error : Null object reference on getResources
How to resolve this and is it possible to pass constant value via dimens file
At January 24, 2020, 10:39pm, mmurphy replied:
context itself is
null, it was not created correctly, or it has been destroyed.
In general, if you want help with crashes, you need to provide a full stack trace, plus a fairly complete set of code that pertains to that stack trace. That is not unique to me and this discussion board — it is fairly common in most support places (GitHub issues, Stack Overflow, etc.).
Sorry, but I do not know what you mean. You are welcome to define dimension resources in values resource directories (e.g.,
res/values/), and you are welcome to reference those dimensions from your Java/Kotlin code by calling methods on a
Resources object. However, to get a
Resources object, you need a valid
Context. And, for something like a dimension, I recommend that it be an
Activity, not some arbitrary other
At January 26, 2020, 3:56pm, Pvr replied:
Declaration of a Constant value like 594(not in dp ) in dimens file is allowed
At January 26, 2020, 4:08pm, mmurphy replied:
You can have
<integer> resources for plain integers, just as you can have
<dimen> resources for dimensions.
At January 26, 2020, 6:44pm, Pvr replied:
I want to know the difference between following code…
I also want to know that
a ) If WindowManager is subclass of ViewGroup,then accessing parent data member which is MATCH_PARENT via subclass not a problem but there might be any chance of ambiguity when MATCH_PARENT is accessed multiple times via WindowManager, if there is ambiguity then calling it via ViewGroup is a better solution or not
At January 26, 2020, 6:57pm, mmurphy replied:
They are identical, as
MATCH_PARENT is defined on
WindowManager.LayoutParams is a subclass of
It is not, though
WindowManager.LayoutParams is a subclass of
I cannot answer that, sorry.
At January 30, 2020, 11:22am, Pvr replied:
I want to apply Transparent property to the text which is present at the bottom part of popup, while scrolling it should not have that transparent property (i.e, completely visible)
how to do this
At January 30, 2020, 12:29pm, mmurphy replied:
Sorry, but I do not know. You are using something for the scrolling (
RecyclerView, etc.). Look for a listener that you can register for scroll events, then modify your view as needed based on those events.
At January 30, 2020, 2:02pm, Pvr replied:
How to set transparent property at a specific area of the textview .
Please provide some reference code .
At January 30, 2020, 2:19pm, mmurphy replied:
BackgroundColorSpan, you can affect the color of a section of text in a
TextView. Beyond that, I am not aware of any options that match my interpretation of what you are describing.
At January 30, 2020, 3:30pm, Pvr replied:
Please consider the dots as Text that needs to be Transparent and the same text not to be transparent while scrolling.
At January 30, 2020, 10:27pm, mmurphy replied:
Sorry, but I have no idea how to do that.
At February 18, 2020, 3:17pm, Pvr replied:
Using android:fadingEdge=“vertical” , I get fading on both Top and Bottom part of my Textview . How to apply this only on bottom part of the Textview
At February 18, 2020, 7:25pm, mmurphy replied:
I have never used this attribute directly. AFAIK, it’s usually handled for you by scrolling containers like
ScrollView. You could look into
getTopFadingEdgeStrength(), but this would require you to make a subclass of
At null, null replied: null