Android BGABadgeView:BGABadgeFrameLayout(5)

来源:互联网 发布:越狱软件下载 编辑:程序博客网 时间:2024/06/10 23:51


Android BGABadgeView:BGABadgeFrameLayout(5)

BGABadgeView除了有自己的线性布局,相对布局外(见附录文章7,8),还实现了FrameLayout。写一个简单例子,布局文件:

<?xml version="1.0" encoding="utf-8"?><LinearLayout 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:background="@mipmap/ic_launcher"    android:orientation="vertical">    <cn.bingoogolapple.badgeview.BGABadgeFrameLayout        android:id="@+id/badgeLayout"        android:layout_width="match_parent"        android:layout_height="200dp"        android:layout_margin="15dp"        android:background="#CCFFFFFF"        app:badge_borderColor="@android:color/black"        app:badge_borderWidth="2dp"        app:badge_gravity="rightTop"        app:badge_padding="10dp"></cn.bingoogolapple.badgeview.BGABadgeFrameLayout>    <TextView        android:id="@+id/text"        android:layout_width="match_parent"        android:layout_height="200dp"        android:layout_margin="15dp"        android:background="#64000000"        android:gravity="center"        android:text="zhang phil @ csdn"        android:textColor="@android:color/white" /></LinearLayout>


Java代码很简单:

package zhangphil.demo;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.TextView;import cn.bingoogolapple.badgeview.BGABadgeFrameLayout;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        BGABadgeFrameLayout frameLayout= (BGABadgeFrameLayout) findViewById(R.id.badgeLayout);        frameLayout.showCirclePointBadge();        TextView text= (TextView) findViewById(R.id.text);        //Color.argb(100, 0, 0, 0),相当于背景中的#64000000        //text.setBackgroundColor(Color.argb(100, 0, 0, 0));    }}


代码运行结果:


附录文章:
1,《仿微信、短信、QQ等消息数目右上角红色小圆球气泡显示(基于Android XML布局文件实现)》链接地址:http://blog.csdn.net/zhangphil/article/details/43702953 
2,《仿短信条目右上角的红色小圆球提示气泡》链接地址:http://blog.csdn.net/zhangphil/article/details/43667727
3,《Android开源BezierView:仿QQ未读消息99+条的红色气泡》链接地址:http://blog.csdn.net/zhangphil/article/details/49746709
4,《Android RoundedBitmapDrawable:Android官方的圆角图形图象实现方案》链接地址:http://blog.csdn.net/zhangphil/article/details/51829650
5,《Android BGABadgeView:新消息/未接来电/未读消息/新通知圆球红点提示(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51822514
6,《Android BGABadgeView:显示提示数字(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/51828808
7,《Android BGABadgeView:BGABadgeLinearLayout以整体线性布局作为BadgeView(3)》链接地址:http://blog.csdn.net/zhangphil/article/details/51828968
8,《Android BGABadgeView:BGABadgeImageView以及BGABadgeRelativeLayout(4)》链接地址:http://blog.csdn.net/zhangphil/article/details/51830489


0 0