Small library that provides Foreground View functionality to most used Android Views with foreground. If you want support to new View, add an issue :-)
This library is developed based on some other good but not completed approaches of Foreground Views:
- FRelativeLayout made by Shaka Huang
- Antonie Merle post about how custom Foreground Views should work
- Chris Banes post that explains which possibilities we have to get the Foreground Approach on Android
- FrameLayout source code
You just have to use whatever FView like FrameLayout; just set the android:foreground attribute as shown below:
<com.cesards.android.foregroundviews.ForegroundView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
custom:?="?">
... other views ...
</com.cesards.android.foregroundviews.FView>
where custom attributes can be:
-
foreground Defines the drawable to draw over the content. This can be used as an overlay.
Just add:
custom:foreground="@drawable/your_foreground"
-
foregroundInsidePadding Defines whether the foreground drawable should be drawn inside the padding. This property is false by default except if your background is a NinePatch Drawable.
Just add:
custom:foregroundInsidePadding="true"
-
backgroundAsForeground Retrieve the default background and set it as the foreground. Thanks to this, you can get the default background selector of your theme and set it as your foreground selector if you want. This property is false by default.
Just add:
custom:foregroundInsidePadding="true"
Not yet.
Download the latest JAR or grab via Maven:
<! -- Coming soon -->
or Gradle:
# Coming soon
- César Díez Sánchez - cesaryomismo@gmail.com
Copyright 2014 DogmaLabs
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
http://www.apache.org/licenses/LICENSE-2.0
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.