What is android:layout_gravity="clip_vertical" exactly -
the property android:layout_gravity="clip_vertical|horizontal" following mentioned in sdk documentation:
additional option can set have top and/or bottom edges of child clipped container's bounds. clip based on vertical gravity: top gravity clip bottom edge, bottom gravity clip top edge, , neither clip both edges.
but can't see of in applications
so purpose of property ?
thanks
short version:
clip_horizontal , clip_vertical apply measurements of view itself, before contents (such image in bitmapdrawable) rendered.
long version:
i've run similar confusion on clip_horizontal , clip_vertical. (in case, related android:gravity bitmapdrawable, it's similar enough applicable.)
from documentation thought android:gravity="top|left|clip_vertical" on bitmap cause image's top left corner positioned @ view's top left corner, , that, if bitmap taller view, "clipped" @ bottom edge of view. in other words, show of bitmap view tall enough reveal; not stretch bitmap, instead show whatever fit, letting rest extend below bottom edge.
however, opposite happened: when set clip_vertical, large bitmap squished vertically fit within height of view.
after examining applydisplay() method in platform/frameworks/core/java/android/view/gravity.java, realized mistake:
it isn't bitmap image going clipped, view -- actual size of container image rendered into.
setting clip_vertical in case didn't mean "clip image @ bottom edge," meant "clip bitmapdrawable's view height matches height of parent container"...which caused image "squished" filled shorter height.
so, important thing remember android:gravity , android:layout_gravity clip_horizontal , clip_vertical apply measurements of view itself, before contents (such bitmapdrawable) rendered.
Comments
Post a Comment