1
我正在開發一個Wear手錶,我得到一個非常不尋常的輸出。有一個神祕的圈子區域,其中一些子視圖沒有完全呈現。有趣的是我從不在視圖中添加一個圓圈。Android Wear上怪異的渲染問題
下面是輸出的屏幕截圖:
奇怪的是時鐘指針被輸出就好了,他們被添加到視圖第一。下面是繪製行代碼的SNIPPIT:
for(int i=1; i<=60; i++) {
int seconds = i;
int radius = (screenWidth/2);
int centre = (screenWidth/2);
int totalLimit = 60;
int currentValue = seconds;
int theta = (360/totalLimit) * currentValue;
double x = centre + radius * Math.cos(theta * Math.PI/180);
double y = centre + radius * Math.sin(theta * Math.PI/180);
float angle = (float) Math.toDegrees(Math.atan2(x - centre, y - centre));
if (angle < 0) {
angle += 360;
}
if (angle > 180)
angle -= 180;
else
angle += 180;
View view = new View(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, radius);
params.leftMargin = (int)x;
params.topMargin = (int)y;
view.setPivotX(0);
view.setPivotY(0);
view.setRotation(-angle);
view.setBackgroundColor(Color.WHITE);
mWatchView.addView(view, params);
views.add(view);
}
感謝。我如何在x,y上添加視圖然後旋轉它,但仍保留其長度的任何提示? – Eeshwar 2014-09-04 17:23:36