0

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

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
osimer pothe
  • 2,827
  • 14
  • 54
  • 92

1 Answers1

1

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;
PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • I want to put this badge at the right of textview . What can I do this ? – osimer pothe Sep 20 '15 at 09:34
  • @osimerpothe Use one of the constants above, i.e. `setBadgePosition(BadgeView.POSITION_TOP_RIGHT);` – PPartisan Sep 20 '15 at 09:36
  • Using setBadgePosition(BadgeView.POSITION_TOP_RIGHT); the badge does not appear in the right of textview . – osimer pothe Sep 20 '15 at 09:36
  • 1
    @osimerpothe Take a look at Frank N Stein's comment on your original post. In the [ReadMe](https://github.com/jgilfelt/android-viewbadger/blob/master/README.markdown) file for this library it states limitations, one of which is that a `RelativeLayout` may break alignment. – PPartisan Sep 20 '15 at 09:39
  • But the parent container is LinearLayout – osimer pothe Sep 20 '15 at 10:01
  • @osimerpothe Is your `TextView` `width` attribute set to `match_parent`? Chance are there's some padding involved that's pushing it closer to the centre if you use `wrap_content` – PPartisan Sep 20 '15 at 10:10