如何添加mpandroidchart折线图触摸点值显示带有线条颜色背景的标记视图
我的期望
我的编码
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();
}
}