有没有办法让 MarkerView 固定位置?我需要在 修复它左上或 右上角角落。
最佳答案
这是将标记固定在左上角或右上角的一种方法
创建自定义 MarkerView 后,您可以执行以下操作。
1) 您可以为父 View /布局设置一个 id,并使用该 id 可以获得它的宽度。
layoutWidth = customLayout.getWidth();
2) 然后您可以覆盖 draw 并执行以下操作:
@Override
public void draw(Canvas canvas, float posX, float posY) {
if (posX > (canvas.getWidth() / 2.0))
//Check if the user is in the right half of the canvas
super.draw(canvas, leftXPos, leftYPos);
//Draw marker on the left top corner
else
//Otherwise draw the marker on the top right corner.
super.draw(canvas, canvas.getWidth() - layoutWidth, rightYPos);
}
您可以将 leftXPos、leftYPos 和 rightYPos 的值设置为最佳外观和感觉。
希望这可以帮助!
关于MPAndroidChart MarkerView 固定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36954745/