How to add mpandroidchart touch point value display with line color

How to add the display of the value of the point of touch of the line mpandroidchart Marker with a colored background

My expectation

enter image description here

my coding

CustomMarkerView mv = new CustomMarkerView (MainActivity.this, R.layout.tv_content);
chart.setMarkerView(mv);

CustomMarkerView.java

public class CustomMarkerView extends MarkerView {

private TextView tvContent;
public CustomMarkerView (Context context, int layoutResource) {
    super(context, layoutResource);
    // this markerview only displays a textview
    tvContent = (TextView) findViewById(R.id.tvContent);
}

@Override
public void refreshContent(Entry e, Highlight highlight) {
    tvContent.setText("" + e.getVal());
}

@Override
public int getXOffset(float xpos) {
    return -(getWidth() / 2);
}

@Override
public int getYOffset(float ypos) {
    return -getHeight();
}

}

+4
source share

Source: https://habr.com/ru/post/1649108/


All Articles