- 浏览: 5782286 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
项目地址:https://github.com/jgilfelt/android-viewbadger
以前都是自己写的,一不小心网上找到这个,觉得不错,以后直接copy了,方便快捷!
用法:
Android系统 小米/三星/索尼 应用启动图标未读消息数(BadgeNumber)动态提醒
http://blog.csdn.net/janice0529/article/details/44344169
以前都是自己写的,一不小心网上找到这个,觉得不错,以后直接copy了,方便快捷!
package com.readystatesoftware.viewbadger; import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RoundRectShape; import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewParent; import android.view.animation.AccelerateInterpolator; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; import android.widget.TabWidget; import android.widget.TextView; /** * A simple text label view that can be applied as a "badge" to any given {@link android.view.View}. * This class is intended to be instantiated at runtime rather than included in XML layouts. * * @author Jeff Gilfelt */ public class BadgeView extends TextView { public static final int POSITION_TOP_LEFT = 1; public static final int POSITION_TOP_RIGHT = 2; public static final int POSITION_BOTTOM_LEFT = 3; public static final int POSITION_BOTTOM_RIGHT = 4; public static final int POSITION_CENTER = 5; private static final int DEFAULT_MARGIN_DIP = 5; private static final int DEFAULT_LR_PADDING_DIP = 5; private static final int DEFAULT_CORNER_RADIUS_DIP = 8; private static final int DEFAULT_POSITION = POSITION_TOP_RIGHT; private static final int DEFAULT_BADGE_COLOR = Color.parseColor("#CCFF0000"); //Color.RED; private static final int DEFAULT_TEXT_COLOR = Color.WHITE; private static Animation fadeIn; private static Animation fadeOut; private Context context; private View target; private int badgePosition; private int badgeMarginH; private int badgeMarginV; private int badgeColor; private boolean isShown; private ShapeDrawable badgeBg; private int targetTabIndex; public BadgeView(Context context) { this(context, (AttributeSet) null, android.R.attr.textViewStyle); } public BadgeView(Context context, AttributeSet attrs) { this(context, attrs, android.R.attr.textViewStyle); } /** * Constructor - * * create a new BadgeView instance attached to a target {@link android.view.View}. * * @param context context for this view. * @param target the View to attach the badge to. */ public BadgeView(Context context, View target) { this(context, null, android.R.attr.textViewStyle, target, 0); } /** * Constructor - * * create a new BadgeView instance attached to a target {@link android.widget.TabWidget} * tab at a given index. * * @param context context for this view. * @param target the TabWidget to attach the badge to. * @param index the position of the tab within the target. */ public BadgeView(Context context, TabWidget target, int index) { this(context, null, android.R.attr.textViewStyle, target, index); } public BadgeView(Context context, AttributeSet attrs, int defStyle) { this(context, attrs, defStyle, null, 0); } public BadgeView(Context context, AttributeSet attrs, int defStyle, View target, int tabIndex) { super(context, attrs, defStyle); init(context, target, tabIndex); } private void init(Context context, View target, int tabIndex) { this.context = context; this.target = target; this.targetTabIndex = tabIndex; // apply defaults badgePosition = DEFAULT_POSITION; badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP); badgeMarginV = badgeMarginH; badgeColor = DEFAULT_BADGE_COLOR; setTypeface(Typeface.DEFAULT_BOLD); int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP); setPadding(paddingPixels, 0, paddingPixels, 0); setTextColor(DEFAULT_TEXT_COLOR); fadeIn = new AlphaAnimation(0, 1); fadeIn.setInterpolator(new DecelerateInterpolator()); fadeIn.setDuration(200); fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(200); isShown = false; if (this.target != null) { applyTo(this.target); } else { show(); } } private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // TODO verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } } /** * Make the badge visible in the UI. * */ public void show() { show(false, null); } /** * Make the badge visible in the UI. * * @param animate flag to apply the default fade-in animation. */ public void show(boolean animate) { show(animate, fadeIn); } /** * Make the badge visible in the UI. * * @param anim Animation to apply to the view when made visible. */ public void show(Animation anim) { show(true, anim); } /** * Make the badge non-visible in the UI. * */ public void hide() { hide(false, null); } /** * Make the badge non-visible in the UI. * * @param animate flag to apply the default fade-out animation. */ public void hide(boolean animate) { hide(animate, fadeOut); } /** * Make the badge non-visible in the UI. * * @param anim Animation to apply to the view when made non-visible. */ public void hide(Animation anim) { hide(true, anim); } /** * Toggle the badge visibility in the UI. * */ public void toggle() { toggle(false, null, null); } /** * Toggle the badge visibility in the UI. * * @param animate flag to apply the default fade-in/out animation. */ public void toggle(boolean animate) { toggle(animate, fadeIn, fadeOut); } /** * Toggle the badge visibility in the UI. * * @param animIn Animation to apply to the view when made visible. * @param animOut Animation to apply to the view when made non-visible. */ public void toggle(Animation animIn, Animation animOut) { toggle(true, animIn, animOut); } private void show(boolean animate, Animation anim) { if (getBackground() == null) { if (badgeBg == null) { badgeBg = getDefaultBackground(); } setBackgroundDrawable(badgeBg); } applyLayoutParams(); if (animate) { this.startAnimation(anim); } this.setVisibility(View.VISIBLE); isShown = true; } private void hide(boolean animate, Animation anim) { this.setVisibility(View.GONE); if (animate) { this.startAnimation(anim); } isShown = false; } private void toggle(boolean animate, Animation animIn, Animation animOut) { if (isShown) { hide(animate && (animOut != null), animOut); } else { show(animate && (animIn != null), animIn); } } /** * Increment the numeric badge label. If the current badge label cannot be converted to * an integer value, its label will be set to "0". * * @param offset the increment offset. */ public int increment(int offset) { CharSequence txt = getText(); int i; if (txt != null) { try { i = Integer.parseInt(txt.toString()); } catch (NumberFormatException e) { i = 0; } } else { i = 0; } i = i + offset; setText(String.valueOf(i)); return i; } /** * Decrement the numeric badge label. If the current badge label cannot be converted to * an integer value, its label will be set to "0". * * @param offset the decrement offset. */ public int decrement(int offset) { return increment(-offset); } private ShapeDrawable getDefaultBackground() { int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP); float[] outerR = new float[] {r, r, r, r, r, r, r, r}; RoundRectShape rr = new RoundRectShape(outerR, null, null); ShapeDrawable drawable = new ShapeDrawable(rr); drawable.getPaint().setColor(badgeColor); return drawable; } private void applyLayoutParams() { FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); switch (badgePosition) { case POSITION_TOP_LEFT: lp.gravity = Gravity.LEFT | Gravity.TOP; lp.setMargins(badgeMarginH, badgeMarginV, 0, 0); break; case POSITION_TOP_RIGHT: lp.gravity = Gravity.RIGHT | Gravity.TOP; lp.setMargins(0, badgeMarginV, badgeMarginH, 0); break; case POSITION_BOTTOM_LEFT: lp.gravity = Gravity.LEFT | Gravity.BOTTOM; lp.setMargins(badgeMarginH, 0, 0, badgeMarginV); break; case POSITION_BOTTOM_RIGHT: lp.gravity = Gravity.RIGHT | Gravity.BOTTOM; lp.setMargins(0, 0, badgeMarginH, badgeMarginV); break; case POSITION_CENTER: lp.gravity = Gravity.CENTER; lp.setMargins(0, 0, 0, 0); break; default: break; } setLayoutParams(lp); } /** * Returns the target View this badge has been attached to. * */ public View getTarget() { return target; } /** * Is this badge currently visible in the UI? * */ @Override public boolean isShown() { return isShown; } /** * Returns the positioning of this badge. * * one of POSITION_TOP_LEFT, POSITION_TOP_RIGHT, POSITION_BOTTOM_LEFT, POSITION_BOTTOM_RIGHT, POSTION_CENTER. * */ public int getBadgePosition() { return badgePosition; } /** * Set the positioning of this badge. * * @param layoutPosition one of POSITION_TOP_LEFT, POSITION_TOP_RIGHT, POSITION_BOTTOM_LEFT, POSITION_BOTTOM_RIGHT, POSTION_CENTER. * */ public void setBadgePosition(int layoutPosition) { this.badgePosition = layoutPosition; } /** * Returns the horizontal margin from the target View that is applied to this badge. * */ public int getHorizontalBadgeMargin() { return badgeMarginH; } /** * Returns the vertical margin from the target View that is applied to this badge. * */ public int getVerticalBadgeMargin() { return badgeMarginV; } /** * Set the horizontal/vertical margin from the target View that is applied to this badge. * * @param badgeMargin the margin in pixels. */ public void setBadgeMargin(int badgeMargin) { this.badgeMarginH = badgeMargin; this.badgeMarginV = badgeMargin; } /** * Set the horizontal/vertical margin from the target View that is applied to this badge. * * @param horizontal margin in pixels. * @param vertical margin in pixels. */ public void setBadgeMargin(int horizontal, int vertical) { this.badgeMarginH = horizontal; this.badgeMarginV = vertical; } /** * Returns the color value of the badge background. * */ public int getBadgeBackgroundColor() { return badgeColor; } /** * Set the color value of the badge background. * * @param badgeColor the badge background color. */ public void setBadgeBackgroundColor(int badgeColor) { this.badgeColor = badgeColor; badgeBg = getDefaultBackground(); } private int dipToPixels(int dip) { Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); return (int) px; } }
用法:
package viewbadger.demo; import android.app.TabActivity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.animation.BounceInterpolator; import android.view.animation.TranslateAnimation; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TabHost; import android.widget.TabWidget; import android.widget.TextView; import android.widget.Toast; import com.readystatesoftware.viewbadger.BadgeView; import com.readystatesoftware.viewbadger.R; public class DemoActivity extends TabActivity { private static final String[] DATA = Cheeses.sCheeseStrings; Button btnPosition; Button btnColour; Button btnAnim1; Button btnAnim2; Button btnCustom; Button btnClick; Button btnTab; Button btnIncrement; ListView listDemo; BadgeView badge1; BadgeView badge2; BadgeView badge3; BadgeView badge4; BadgeView badge5; BadgeView badge6; BadgeView badge7; BadgeView badge8; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("demos") .setIndicator("Badge Demos") .setContent(R.id.tab1)); tabHost.addTab(tabHost.newTabSpec("adapter") .setIndicator("List Adapter") .setContent(R.id.tab2)); tabHost.addTab(tabHost.newTabSpec("tests") .setIndicator("Layout Tests") .setContent(R.id.tab3)); // *** default badge *** View target = findViewById(R.id.default_target); BadgeView badge = new BadgeView(this, target); badge.setText("1"); badge.show(); // *** set position *** btnPosition = (Button) findViewById(R.id.position_target); badge1 = new BadgeView(this, btnPosition); badge1.setText("12"); badge1.setBadgePosition(BadgeView.POSITION_CENTER); btnPosition.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge1.toggle(); } }); // *** badge/text size & colour *** btnColour = (Button) findViewById(R.id.colour_target); badge2 = new BadgeView(this, btnColour); badge2.setText("New!"); badge2.setTextColor(Color.BLUE); badge2.setBadgeBackgroundColor(Color.YELLOW); badge2.setTextSize(12); btnColour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge2.toggle(); } }); // *** default animation *** btnAnim1 = (Button) findViewById(R.id.anim1_target); badge3 = new BadgeView(this, btnAnim1); badge3.setText("84"); btnAnim1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge3.toggle(true); } }); // *** custom animation *** btnAnim2 = (Button) findViewById(R.id.anim2_target); badge4 = new BadgeView(this, btnAnim2); badge4.setText("123"); badge4.setBadgePosition(BadgeView.POSITION_TOP_LEFT); badge4.setBadgeMargin(15, 10); badge4.setBadgeBackgroundColor(Color.parseColor("#A4C639")); btnAnim2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0); anim.setInterpolator(new BounceInterpolator()); anim.setDuration(1000); badge4.toggle(anim, null); } }); // *** custom background *** btnCustom = (Button) findViewById(R.id.custom_target); badge5 = new BadgeView(this, btnCustom); badge5.setText("37"); badge5.setBackgroundResource(R.drawable.badge_ifaux); badge5.setTextSize(16); btnCustom.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge5.toggle(true); } }); // *** clickable badge *** btnClick = (Button) findViewById(R.id.click_target); badge6 = new BadgeView(this, btnClick); badge6.setText("click me"); badge6.setBadgeBackgroundColor(Color.BLUE); badge6.setTextSize(16); badge6.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(DemoActivity.this, "clicked badge", Toast.LENGTH_SHORT).show(); } }); btnClick.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge6.toggle(); } }); // *** tab *** TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs); btnTab = (Button) findViewById(R.id.tab_btn); badge7 = new BadgeView(this, tabs, 0); badge7.setText("5"); btnTab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { badge7.toggle(); } }); // *** increment *** btnIncrement = (Button) findViewById(R.id.increment_target); badge8 = new BadgeView(this, btnIncrement); badge8.setText("0"); btnIncrement.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (badge8.isShown()) { badge8.increment(1); } else { badge8.show(); } } }); // *** list adapter **** listDemo = (ListView) findViewById(R.id.tab2); listDemo.setAdapter(new BadgeAdapter(this)); } @Override protected void onResume() { super.onResume(); BadgeView badge; View target; // *** test linear layout container *** target = findViewById(R.id.linear_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test relative layout container *** target = findViewById(R.id.relative_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test frame layout container *** target = findViewById(R.id.frame_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test table layout container *** target = findViewById(R.id.table_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test linear layout *** target = findViewById(R.id.linear_group_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test relative layout *** target = findViewById(R.id.relative_group_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test frame layout *** target = findViewById(R.id.frame_group_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); // *** test table layout *** target = findViewById(R.id.tablerow_group_target); badge = new BadgeView(this, target); badge.setText("OK"); badge.show(); } private static class BadgeAdapter extends BaseAdapter { private LayoutInflater mInflater; private Context mContext; private static final int droidGreen = Color.parseColor("#A4C639"); public BadgeAdapter(Context context) { mInflater = LayoutInflater.from(context); mContext = context; } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(android.R.layout.simple_list_item_2, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(android.R.id.text1); holder.badge = new BadgeView(mContext, holder.text); holder.badge.setBadgeBackgroundColor(droidGreen); holder.badge.setTextColor(Color.BLACK); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); if (position % 3 == 0) { holder.badge.setText(String.valueOf(position)); holder.badge.show(); } else { holder.badge.hide(); } return convertView; } static class ViewHolder { TextView text; BadgeView badge; } } }
Android系统 小米/三星/索尼 应用启动图标未读消息数(BadgeNumber)动态提醒
http://blog.csdn.net/janice0529/article/details/44344169
发表评论
-
NestedScrollView滚动到顶部固定子View悬停挂靠粘在顶端
2018-10-31 20:45 6820网上有一个StickyScrollView,称之为粘性Scro ... -
自定义Behavior实现AppBarLayout越界弹性效果
2017-03-31 09:33 10257一、继承AppBarLayout.Beha ... -
Android - 一种相似图片搜索算法的实现
2017-03-31 09:33 2576算法 缩小尺寸。 将图片缩小到8x8的尺寸,总共64个 ... -
使用SpringAnimation实现带下拉弹簧动画的 ScrollView
2017-03-30 11:30 2802在刚推出的 Support Library 25.3.0 里面 ... -
Android为应用添加角标(Badge)
2017-03-30 11:21 61131.需求简介 角标是什么意思呢? 看下图即可明了: 可 ... -
Android端与笔记本利用局域网进行FTP通信
2017-03-23 10:17 934先看图 打开前: 打开后: Activity类 ... -
PorterDuffColorFilter 在项目中的基本使用
2017-03-03 10:58 1306有时候标题栏会浮在内容之上,而内容会有颜色的变化,这时候就要求 ... -
ColorAnimationView 实现了滑动Viewpager 时背景色动态变化的过渡效果
2017-02-24 09:41 2181用法在注释中: import android.anima ... -
迷你轻量级全方向完美滑动处理侧滑控件SlideLayout
2017-01-16 16:53 2555纯手工超级迷你轻量级全方向完美滑动处理侧滑控件(比官方 sup ... -
Effect
2017-01-05 09:57 0https://github.com/JetradarMobi ... -
动态主题库Colorful,容易地改变App的配色方案
2016-12-27 14:49 2531Colorful是一个动态主题库,允许您很容易地改变App的配 ... -
对视图的对角线切割DiagonalView
2016-12-27 14:23 1079提供对视图的对角线切割,具有很好的用户定制 基本用法 ... -
仿淘宝京东拖拽商品详情页上下滚动黏滞效果
2016-12-26 16:53 3428比较常用的效果,有现成的,如此甚好!:) import ... -
让任意view具有滑动效果的SlideUp
2016-12-26 09:26 1671基本的类,只有一个: import android.a ... -
AdvancedWebView
2016-12-21 09:44 16https://github.com/delight-im/A ... -
可设置圆角背景边框的按钮, 通过调节色彩明度自动计算按下(pressed)状态颜色
2016-11-02 22:13 1870可设置圆角背景边框的的按钮, 通过调节色彩明度自动计算按下(p ... -
网络请求库相关
2016-10-09 09:35 62https://github.com/amitshekhari ... -
ASimpleCache一个简单的缓存框架
2015-10-26 22:53 2129ASimpleCache 是一个为android制定的 轻量级 ... -
使用ViewDragHelper实现的DragLayout开门效果
2015-10-23 10:55 3351先看一下图,有个直观的了解,向下拖动handle就“开门了”: ... -
保证图片长宽比的同时拉伸图片ImageView
2015-10-16 15:40 3683按比例放大图片,不拉伸失真 import android. ...
相关推荐
本项目是一个给view添加红色数字标签的小例子源码,这个开源项目提供了一种简便的方式,能够在运行期对任意给定的Android view添加徽章, 而不必配合它的布局。可添加的标签包括但不限于右上角的红色数字提醒角标。
底部的tabbar 添加自定义角标条数显示!很方便的自动添加对应的地方!
用fragment+viewpager实现tab,其中通过自定义让viewpager不能滑动,用bageview为viewgroup和view添加角标
本项目是一个给view添加红色数字标签的小例子源码,这个开源项目提供了一...可添加的标签包括但不限于右上角的红色数字提醒角标。详细的使用方法可以参考这里:http://blog.csdn.net/t12x3456/article/details/9337555
作为收藏,BadgeView---角标,给View添加各种角标。
该自定义view支持对多个视图控件添加角标,集成简单方便
Sometimes, we need to show a label above an ImageView or any other views. Well, LabelXXView will be able to help you. It's easy to implement as well! Import your project Gradle Step 1. Add the ...
本项目是一个给view添加红色数字标签的小例子源码,这个开源项目提供了一种简便的方式,能够在运行期对任意给定的Android view添加徽章, 而不必配合它的布局。可添加的标签包括但不限于右上角的红色数字提醒角标。
本项目是一个给view添加红色数字标签的小例子源码,这个开源项目提供了一种简便的方式,能够在运行期对任意给定的Android view添加徽章, 而不必配合它的布局...可添加的标签包括但不限于右上角的红色数字提醒角标。
为Android视图添加徽章:Android ViewBadgerjgilfelt-android-viewbadger-f1cf577.
android viewbadger jar包,将jar包添加到你的Android lib 目录,然后将其添加到构建路径中,在代码中按如下方式设置需要显示悬浮数字的控件。 View target = findViewById(R.id.target_view); BadgeView badge = ...
//一般view上加角标 _badge1 = [[LFBadge alloc] init]; [_badge1 addToTabBarItem:_view1]; //BarButtonItem上加角标 _badge2 = [[LFBadge alloc] init]; [_badge2 addToBarButtonItem:self.navigationItem....
BadgedView 能够为任意一个 View 添加矩形或三角形标签。 BadgedImageView 就是 Plaid 和 虎扑体育 用来给图片添加标签的控件。原作者的实现里,只能为 ImageView 添加 Badge,我看了看他的代码(开源)发现这个控件...
给布局,控件添加阴影效果 使用属性 elevation ,layer-list
图1、右上角的购物车即是我们定义的view 实现原理: 1、利用 navigationItem 可以将 UIView 设置为导航栏的按钮; 2、将一个 UIButton 和 一个 UILabel 添加到一个 UIView 上。然后将这个 UIView 设置为 ...
一个方便为Android View添加自然的阴影的库
给view添加点击 block回调