BadgedView
BadgedView ??????? View ???????????
BadgedImageView ?? Plaid ? ???? ???????????????????????? ImageView ?? Badge?????????? ????????????????????????????????????????????????????? View ??????????????? BadgedView?
????
#Feature
Implemented
- ????????
- ????????
- ??????????
- ???????? View
- ??????????????
- ???????????????????
- ??? View ?????????????
Processing
- ?????????
- ????????????? View ????????
#Usage
##Dependency
###Min SDK?2.3.3
###Add Dependency
???? build.gradle ????
dependencies {
...
compile 'com.github.chaossss:BadgedView:1.1.1'
}
##Attr
Attr | usage |
---|---|
app:badgeText | ?????????? |
app:badgeTextSize | ???????????? |
app:badgeTextColor | ???????????? |
app:badgePadding | ??????????????? |
app:badgeWidthRatio | ?????????? |
app:badgeHeightRatio | ?????????? |
app:badgeCornerRadius | ??????????? |
app:recbadgeGravity(RecBadgedView) | ????????? |
app:tribadgeGravity(TriBadgedView) | ????????? |
##API
API | usage |
---|---|
showBadge(boolean show) | ???? |
setBadgeText(String newText) | ???????? |
##Customize BadgedView
- ?? BadgedView??? BadgedView ???????????
- ????????????????
- ?? initBadge(Context context) ? draw(Canvas canvas) ?????????
??????????
- ?? BaseBadge
- ????????????????
- ?? initBadge()????? badge ??????????????
##Activity
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private RecBadgedView anyView;
private RecBadgedView scaleView;
private RecBadgedView regularView;
private TriBadgedView triView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
anyView = (RecBadgedView) findViewById(R.id.badge_any_view);
scaleView = (RecBadgedView) findViewById(R.id.badge_scale_view);
regularView = (RecBadgedView) findViewById(R.id.badge_regular_view);
triView = (TriBadgedView) findViewById(R.id.badge_tri_view);
anyView.setBadgeText("I'm badge");
anyView.setOnClickListener(this);
anyView.showBadge(true);
scaleView.showBadge(true);
regularView.showBadge(true);
triView.showBadge(true);
}
@Override
public void onClick(View v) {
if(anyView.isBadgeVisible()){
anyView.showBadge(false);
}
else {
anyView.showBadge(true);
}
}
}
##XML
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.chaos.customview.badgeview.view.RecBadgedView
android:id="@+id/badge_scale_view"
android:layout_width="200dp"
android:layout_height="200dp"
android:foreground="?selectableItemBackground"
app:recbadgeGravity="bottom|right"
app:badgeWidthRatio="2"
app:badgeHeightRatio="4"
app:badgeColor="@color/colorAccent"
app:badgeText="@string/lab_gif" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/gem"/>
</com.chaos.customview.badgeview.view.RecBadgedView>
<com.chaos.customview.badgeview.view.RecBadgedView
android:id="@+id/badge_regular_view"
android:layout_width="200dp"
android:layout_height="200dp"
android:foreground="?selectableItemBackground"
app:badgeColor="@color/colorAccent"
app:recbadgeGravity="bottom|left"
app:badgeText="@string/lab_gif" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/hebe"/>
</com.chaos.customview.badgeview.view.RecBadgedView>
<com.chaos.customview.badgeview.view.RecBadgedView
android:id="@+id/badge_any_view"
android:layout_width="200dp"
android:layout_height="200dp"
android:foreground="?selectableItemBackground"
app:recbadgeGravity="top|right"
app:badgeText="@string/lab_gif" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="btn"/>
</com.chaos.customview.badgeview.view.RecBadgedView>
<com.chaos.customview.badgeview.view.TriBadgedView
android:id="@+id/badge_tri_view"
android:layout_width="200dp"
android:layout_height="200dp"
app:badgeText="@string/lab_gif">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/hebe"/>
</com.chaos.customview.badgeview.view.TriBadgedView>
</LinearLayout> </ScrollView>