當前位置:首頁 » 安卓系統 » android角標

android角標

發布時間: 2022-01-12 08:33:36

① Android桌面角標提醒功能

問下三星的如何設置桌面的軟體圖標右上角數字提醒,小米手機已經實現了,沒找到三星的介面,問下你在哪裡找到的

② android角標怎麼讓它一直顯示

TextViewellipsize屬性,作用文字,該控制項該何顯示,解釋:
android:ellipsize=start—–省略號顯示
android:ellipsize=end——省略號顯示結尾
android:ellipsize=middle—-省略號顯示間
android:ellipsize=marquee–跑馬燈式顯示(畫橫向移)
文字左右滾三屬性:
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"

③ android 微信 角標 怎麼實現

是桌面角標嗎 ,如果是桌面角標每個廠家的定製系統不同需要系統廠商提供的API方法,小米、華為、三星都用自己的調用方法,以小米為例:
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(this)
.setContentTitle(「title」).setContentText(「text」).setSmallIcon(R.drawable.icon);
Notification notification = builder.build();
try {
Field field = notification.getClass().getDeclaredField(「extraNotification」);
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod(「setMessageCount」, int.class);
method.invoke(extraNotification, mCount);
} catch (Exception e) {
e.printStackTrace();
}
mNotificationManager.notify(0,notification);
參考地址:http://dev.xiaomi.com/doc/p=3904/

④ android中badgeview如何去掉角標重復添加

先設置一個全局變數,當添加了角標後將變數賦一個值
通過if來判斷,如果變數已經是指定的值,就不需要再添加了

⑤ Android 桌面角標怎麼實現,網上搜了沒有效果

public class MainActivity extends Activity {
//必須使用,Activity啟動頁
private final static String lancherActivityClassName = Welcome.class.getName();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.common_listview_layout);
}

@Override
protected void onResume() {
super.onResume();
sendBadgeNumber();
}

private void sendBadgeNumber() {
String number = "35";
if (TextUtils.isEmpty(number)) {
number = "0";
} else {
int numInt = Integer.valueOf(number);
number = String.valueOf(Math.max(0, Math.min(numInt, 99)));
}

if (Build.MANUFACTURER.equalsIgnoreCase("Xiaomi")) {
sendToXiaoMi(number);
} else if (Build.MANUFACTURER.equalsIgnoreCase("samsung")) {
sendToSony(number);
} else if (Build.MANUFACTURER.toLowerCase().contains("sony")) {
sendToSamsumg(number);
} else {
Toast.makeText(this, "Not Support", Toast.LENGTH_LONG).show();
}
}

private void sendToXiaoMi(String number) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = null;
boolean isMiUIV6 = true;
try {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("您有"+number+"未讀消息");
builder.setTicker("您有"+number+"未讀消息");
builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.common_icon_lamp_light_red);
builder.setDefaults(Notification.DEFAULT_LIGHTS);
notification = builder.build();
Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField("messageCount");
field.setAccessible(true);
field.set(miuiNotification, number);// 設置信息數
field = notification.getClass().getField("extraNotification");
field.setAccessible(true);
field.set(notification, miuiNotification);
Toast.makeText(this, "Xiaomi=>isSendOk=>1", Toast.LENGTH_LONG).show();
}catch (Exception e) {
e.printStackTrace();
//miui 6之前的版本
isMiUIV6 = false;
Intent localIntent = new Intent("android.intent.action.APPLICATION_MESSAGE_UPDATE");
localIntent.putExtra("android.intent.extra.update_application_component_name",getPackageName() + "/"+ lancherActivityClassName );
localIntent.putExtra("android.intent.extra.update_application_message_text",number);
sendBroadcast(localIntent);
}
finally
{
if(notification!=null && isMiUIV6 )
{
//miui6以上版本需要使用通知發送
nm.notify(101010, notification);
}
}

}

private void sendToSony(String number) {
boolean isShow = true;
if ("0".equals(number)) {
isShow = false;
}
Intent localIntent = new Intent();
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE",isShow);//是否顯示
localIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME",lancherActivityClassName );//啟動頁
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", number);//數字
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME",getPackageName());//包名
sendBroadcast(localIntent);

Toast.makeText(this, "Sony," + "isSendOk", Toast.LENGTH_LONG).show();
}

private void sendToSamsumg(String number)
{
Intent localIntent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
localIntent.putExtra("badge_count", number);//數字
localIntent.putExtra("badge_count_package_name", getPackageName());//包名
localIntent.putExtra("badge_count_class_name",lancherActivityClassName ); //啟動頁
sendBroadcast(localIntent);
Toast.makeText(this, "Samsumg," + "isSendOk", Toast.LENGTH_LONG).show();
}
}

⑥ Android studio預覽頁面出不來,java文件有紅色J角標

1、在Android studio中進行打開一個項目的文件,然後在Java的文件下進行創建一個activity的文件,進行選中目錄文件。 2,進行點擊Android studio軟體菜單的「file」的選項。 3、彈出了下拉的菜單中,進行選擇菜單中的「new」的選項 4、點擊完new的選項,就會彈出了下一級的菜單中進行選擇一個為「activity」的選項。 5、在activity中提供了多個activity的模板的文件,可以進行使用這些模板進行創建activity的文件。 6、就會彈出了一個activity的窗口的,在activity name的名稱中進行輸入昵稱,然後直接進行點擊「finish」的選項。 7、這樣在項目中的activity的創建成功了,這個activity的登錄界面就創建成功了。

⑦ 如何關閉android 應用角標

我覺得你應該先說一下你的手機型號,不同品牌不同型號的手機設置方式都是不一樣的

⑧ 為什麼ANDROID O的角標是個圓點,而不是數字

安卓奧利奧的新特性啊,launcher設置中可以設置的

⑨ android 怎麼畫選擇框角標

你畫的圖形是在"對象繪制"狀態下。 在繪圖工具欄選項下面,有一個"對象繪制"按鈕(磁鐵工具左邊),將它按起來,就可以了。

⑩ android 角標紅點怎麼設置

角標實現

要實現這個角標:

1、放置一個隱藏的圖片在app中,在需要它顯示的時候,顯示該圖片,並以該圖片為背景,顯示新增消息數;

2、自定義一個控制項,用於顯示該角標信息。例如,角標相對於控制項的位置、底色、數字等;

對比或者使用後,你會發現,自定義一個控制項,無疑更符合我們的使用習慣。無需特定的圖片,減少了app的大小等,更重要的是,這樣方便我們的使用。

在角標實現中,有個開源代碼BadgeView寫的很符合我們的心理預期。實現了我們常用的所有功能。

BadgeView

這是一個繼承TextView控制項,自定義而成的一個簡單控制項。我們通過它,可輕易實現對角標位置、角標底色、角標內容等控制。


packagecom.readystatesoftware.viewbadger;

importandroid.content.Context;
importandroid.content.res.Resources;
importandroid.graphics.Color;
importandroid.graphics.Typeface;
importandroid.graphics.drawable.ShapeDrawable;
importandroid.graphics.drawable.shapes.RoundRectShape;
importandroid.util.AttributeSet;
importandroid.util.TypedValue;
importandroid.view.Gravity;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.view.ViewGroup.LayoutParams;
importandroid.view.ViewParent;
importandroid.view.animation.AccelerateInterpolator;
importandroid.view.animation.AlphaAnimation;
importandroid.view.animation.Animation;
importandroid.view.animation.DecelerateInterpolator;
importandroid.widget.FrameLayout;
importandroid.widget.TabWidget;
importandroid.widget.TextView;

/**
*"badge"toanygiven{@linkandroid.view.View}.
*outs.
*
*@authorJeffGilfelt
*/
{

publicstaticfinalintPOSITION_TOP_LEFT=1;
publicstaticfinalintPOSITION_TOP_RIGHT=2;
publicstaticfinalintPOSITION_BOTTOM_LEFT=3;
publicstaticfinalintPOSITION_BOTTOM_RIGHT=4;
publicstaticfinalintPOSITION_CENTER=5;

privatestaticfinalintDEFAULT_MARGIN_DIP=5;
privatestaticfinalintDEFAULT_LR_PADDING_DIP=5;
privatestaticfinalintDEFAULT_CORNER_RADIUS_DIP=8;
privatestaticfinalintDEFAULT_POSITION=POSITION_TOP_RIGHT;
privatestaticfinalintDEFAULT_BADGE_COLOR=Color.parseColor("#CCFF0000");//Color.RED;
privatestaticfinalintDEFAULT_TEXT_COLOR=Color.WHITE;

privatestaticAnimationfadeIn;
privatestaticAnimationfadeOut;

privateContextcontext;
privateViewtarget;

privateintbadgePosition;
privateintbadgeMarginH;
privateintbadgeMarginV;
privateintbadgeColor;

privatebooleanisShown;

privateShapeDrawablebadgeBg;

privateinttargetTabIndex;

publicBadgeView(Contextcontext){
this(context,(AttributeSet)null,android.R.attr.textViewStyle);
}

publicBadgeView(Contextcontext,AttributeSetattrs){
this(context,attrs,android.R.attr.textViewStyle);
}

/**
*Constructor-
*
*{@linkandroid.view.View}.
*
*@.
*@.
*/
publicBadgeView(Contextcontext,Viewtarget){
this(context,null,android.R.attr.textViewStyle,target,0);
}

/**
*Constructor-
*
*{@linkandroid.widget.TabWidget}
*tabatagivenindex.
*
*@.
*@.
*@.
*/
publicBadgeView(Contextcontext,TabWidgettarget,intindex){
this(context,null,android.R.attr.textViewStyle,target,index);
}

publicBadgeView(Contextcontext,AttributeSetattrs,intdefStyle){
this(context,attrs,defStyle,null,0);
}

publicBadgeView(Contextcontext,AttributeSetattrs,intdefStyle,Viewtarget,inttabIndex){
super(context,attrs,defStyle);
init(context,target,tabIndex);
}

privatevoidinit(Contextcontext,Viewtarget,inttabIndex){

this.context=context;
this.target=target;
this.targetTabIndex=tabIndex;

//applydefaults
badgePosition=DEFAULT_POSITION;
badgeMarginH=dipToPixels(DEFAULT_MARGIN_DIP);
badgeMarginV=badgeMarginH;
badgeColor=DEFAULT_BADGE_COLOR;

setTypeface(Typeface.DEFAULT_BOLD);
intpaddingPixels=dipToPixels(DEFAULT_LR_PADDING_DIP);
setPadding(paddingPixels,0,paddingPixels,0);
setTextColor(DEFAULT_TEXT_COLOR);

fadeIn=newAlphaAnimation(0,1);
fadeIn.setInterpolator(newDecelerateInterpolator());
fadeIn.setDuration(200);

fadeOut=newAlphaAnimation(1,0);
fadeOut.setInterpolator(newAccelerateInterpolator());
fadeOut.setDuration(200);

isShown=false;

if(this.target!=null){
applyTo(this.target);
}else{
show();
}

}

privatevoidapplyTo(Viewtarget){

LayoutParamslp=target.getLayoutParams();
ViewParentparent=target.getParent();
FrameLayoutcontainer=newFrameLayout(context);

if(targetinstanceofTabWidget){

//
target=((TabWidget)target).getChildTabViewAt(targetTabIndex);
this.target=target;

((ViewGroup)target).addView(container,
newLayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));

this.setVisibility(View.GONE);
container.addView(this);

}else{

//
ViewGroupgroup=(ViewGroup)parent;
intindex=group.indexOfChild(target);

group.removeView(target);
group.addView(container,index,lp);

container.addView(target);

this.setVisibility(View.GONE);
container.addView(this);

group.invalidate();

}

}

/**
*MakethebadgevisibleintheUI.
*
*/
publicvoidshow(){
show(false,null);
}

/**
*MakethebadgevisibleintheUI.
*
*@-inanimation.
*/
publicvoidshow(booleananimate){
show(animate,fadeIn);
}

/**
*MakethebadgevisibleintheUI.
*
*@.
*/
publicvoidshow(Animationanim){
show(true,anim);
}

/**
*Makethebadgenon-visibleintheUI.
*
*/
publicvoidhide(){
hide(false,null);
}

/**
*Makethebadgenon-visibleintheUI.
*
*@-outanimation.
*/
publicvoidhide(booleananimate){
hide(animate,fadeOut);
}

/**
*Makethebadgenon-visibleintheUI.
*
*@-visible.
*/
publicvoidhide(Animationanim){
hide(true,anim);
}

/**
*.
*
*/
publicvoidtoggle(){
toggle(false,null,null);
}

/**
*.
*
*@-in/outanimation.
*/
publicvoidtoggle(booleananimate){
toggle(animate,fadeIn,fadeOut);
}

/**
*.
*
*@.
*@-visible.
*/
publicvoidtoggle(AnimationanimIn,AnimationanimOut){
toggle(true,animIn,animOut);
}

privatevoidshow(booleananimate,Animationanim){
if(getBackground()==null){
if(badgeBg==null){
badgeBg=getDefaultBackground();
}
setBackgroundDrawable(badgeBg);
}
applyLayoutParams();

if(animate){
this.startAnimation(anim);
}
this.setVisibility(View.VISIBLE);
isShown=true;
}

privatevoidhide(booleananimate,Animationanim){
this.setVisibility(View.GONE);
if(animate){
this.startAnimation(anim);
}
isShown=false;
}

privatevoidtoggle(booleananimate,AnimationanimIn,AnimationanimOut){
if(isShown){
hide(animate&&(animOut!=null),animOut);
}else{
show(animate&&(animIn!=null),animIn);
}
}

/**
*Incrementthenumericbadgelabel.
*anintegervalue,itslabelwillbesetto"0".
*
*@paramoffsettheincrementoffset.
*/
publicintincrement(intoffset){
CharSequencetxt=getText();
inti;
if(txt!=null){
try{
i=Integer.parseInt(txt.toString());
}catch(NumberFormatExceptione){
i=0;
}
}else{
i=0;
}
i=i+offset;
setText(String.valueOf(i));
returni;
}

/**
*Decrementthenumericbadgelabel.
*anintegervalue,itslabelwillbesetto"0".
*
*@paramoffsetthedecrementoffset.
*/
publicintdecrement(intoffset){
returnincrement(-offset);
}

(){

intr=dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
float[]outerR=newfloat[]{r,r,r,r,r,r,r,r};

RoundRectShaperr=newRoundRectShape(outerR,null,null);
ShapeDrawabledrawable=newShapeDrawable(rr);
drawable.getPaint().setColor(badgeColor);

returndrawable;

}

privatevoidapplyLayoutParams(){

FrameLayout.LayoutParamslp=newFrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);

switch(badgePosition){
casePOSITION_TOP_LEFT:
lp.gravity=Gravity.LEFT|Gravity.TOP;
lp.setMargins(badgeMarginH,badgeMarginV,0,0);
break;
casePOSITION_TOP_RIGHT:
lp.gravity=Gravity.RIGHT|Gravity.TOP;
lp.setMargins(0,badgeMarginV,badgeMarginH,0);
break;
casePOSITION_BOTTOM_LEFT:
lp.gravity=Gravity.LEFT|Gravity.BOTTOM;
lp.setMargins(badgeMarginH,0,0,badgeMarginV);
break;
casePOSITION_BOTTOM_RIGHT:
lp.gravity=Gravity.RIGHT|Gravity.BOTTOM;
lp.setMargins(0,0,badgeMarginH,badgeMarginV);
break;
casePOSITION_CENTER:
lp.gravity=Gravity.CENTER;
lp.setMargins(0,0,0,0);
break;
default:
break;
}

setLayoutParams(lp);

}

/**
*.
*
*/
publicViewgetTarget(){
returntarget;
}

/**
*?
*
*/
@Override
publicbooleanisShown(){
returnisShown;
}

/**
*.
*
*oneofPOSITION_TOP_LEFT,POSITION_TOP_RIGHT,POSITION_BOTTOM_LEFT,POSITION_BOTTOM_RIGHT,POSTION_CENTER.
*
*/
publicintgetBadgePosition(){
returnbadgePosition;
}

/**
*Setthepositioningofthisbadge.
*
*@_TOP_LEFT,POSITION_TOP_RIGHT,POSITION_BOTTOM_LEFT,POSITION_BOTTOM_RIGHT,POSTION_CENTER.
*
*/
publicvoidsetBadgePosition(intlayoutPosition){
this.badgePosition=layoutPosition;
}

/**
*.
*
*/
(){
returnbadgeMarginH;
}

/**
*.
*
*/
(){
returnbadgeMarginV;
}

/**
*Setthehorizontal/.
*
*@.
*/
publicvoidsetBadgeMargin(intbadgeMargin){
this.badgeMarginH=badgeMargin;
this.badgeMarginV=badgeMargin;
}

/**
*Setthehorizontal/.
*
*@paramhorizontalmargininpixels.
*@paramverticalmargininpixels.
*/
publicvoidsetBadgeMargin(inthorizontal,intvertical){
this.badgeMarginH=horizontal;
this.badgeMarginV=vertical;
}

/**
*.
*
*/
(){
returnbadgeColor;
}

/**
*.
*
*@.
*/
(intbadgeColor){
this.badgeColor=badgeColor;
badgeBg=getDefaultBackground();
}

privateintdipToPixels(intdip){
Resourcesr=getResources();
floatpx=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dip,r.getDisplayMetrics());
return(int)px;
}

}
熱點內容
裝緩存下載 發布:2024-09-20 05:42:36 瀏覽:72
gon引擎自動回收腳本 發布:2024-09-20 05:39:39 瀏覽:246
好醫生連鎖店密碼多少 發布:2024-09-20 05:09:38 瀏覽:15
魔獸腳本代理 發布:2024-09-20 05:09:35 瀏覽:99
python登陸網頁 發布:2024-09-20 05:08:39 瀏覽:757
安卓qq飛車如何轉蘋果 發布:2024-09-20 04:54:30 瀏覽:178
存儲過程中in什麼意思 發布:2024-09-20 04:24:20 瀏覽:315
php顯示數據 發布:2024-09-20 03:48:38 瀏覽:501
源碼安裝軟體 發布:2024-09-20 03:44:31 瀏覽:354
入門編程游戲的書 發布:2024-09-20 03:31:26 瀏覽:236