osimer pothe
osimer pothe

Reputation: 2897

How to put badge at the right corner of a view

I am trying a badge View as suggested in this link. I am trying with this code .

String count_str = Integer.toString(count);
            TextView text_view = (TextView) findViewById(R.id.textView);
            badge1 = new BadgeView(this, text_view);
            badge1.setText(count_str);  
            badge1.show();

But the badge is appearing in the middle of the TextView. How can I put this badge in the right corner of the TextView?

enter image description here

Upvotes: 0

Views: 427

Answers (1)

PPartisan
PPartisan

Reputation: 8231

Looking at the source code for DemoActivity in this library, it appears the following method is responsible for the position of the badge:

 badge1.setBadgePosition(BadgeView.POSITION_CENTER);

Edit

And the following options from the BadgeView class:

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;

Upvotes: 1

Related Questions