Custom Imageview for Android that allows for setting shapes/borders/shadows efficiently. This is currently in Beta as some minor issues are getting ironed out.
Demo app is coming on the Play Store soon!
Clone the repository and add the library to your project.
Add the custom namespace attribute to your layout
OkulusImageViewto your layout and set the attributes you need
<com.vinaysshenoy.okulus.OkulusImageView android:id="@+id/image_1" android:layout_width="128dp" android:layout_height="96dp" okulus:okulus_fullCircle="true" okulus:okulus_borderWidth="2dp" okulus:okulus_borderColor="#FF0000" okulus:okulus_shadowRadius="0.05" okulus:okulus_shadowWidth="1.5dp" okulus:okulus_shadowColor="#00FF00" />
setImageBitmap()and you're done!
OkulusImageView imageView = findViewById(R.id.image_1); imageView.setImageBitmap(bitmap);
okulus_cornerRadius(dimension)- Sets the corner radius used for adding the rounded corners. Set it to 50% of the width(for a square image) to make it a full circle. Default
okulus_fullCircle(boolean)- If this is set to
true, the entire Bitmap will be drawn as a circle. The width and height will be set to whichever is smaller among them, and
cornerRadiusattribute will be ignored. Default
okulus_borderWidth(dimension)- Sets the width of the border to be drawn. Will be capped at
okulus_borderColor(color)- Sets the color of the border to draw. Default color is
okulus_shadowWidth(dimension)- Sets the width of the shadow to draw. Will be capped at
okulus_shadowColor(color)- Sets the color of the shadow to draw. Default is
okulus_shadowRadius(float)- Defines how sharp the shadow is. Set it to a small value(~0.5) for sharp shadows, and larger values for soft shadows. Default
okulus_touchSelectorColor(color)- Defines the colour of the color overlayed on the view when it is touched. This is ignored if
okulus_touchSelectorEnabled(boolean)- Defines whether the touch selectors should be drawn or not. Default is
- No extra memory used for creating the reshaped Bitmap
- Zero overdraw
- Any combination of shapes - Rounded Rects, Rects, Squares, Circles are possible with borders + shadow
- Supports only fixed dimensions.
wrap_contentcannot be used.
- Does not respect the
ImageView. Scaled Bitmaps need to be provided.
- Shadows cannot be used without borders
- Attributes can only be set through XML
- Shadows are currently drawn to the right and bottom of the View and cannot be changed.
OkulusImageViewfor setting attributes through code
- Respecting ImageView's
Future(in descending order of priority)
- Adding support for
- Adding support for any configuration of shadows
- Adding support for color filters to easily configure effects like Sepia, Grayscale etc.
- Adding support for Image transitions when changing the image content
- Adding support for custom shapes
Copyright 2014 Vinay S Shenoy
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.