3
A
回答
2
這是非標準控制。
我已經實現了它。我已經用簡單的方法完成了,只需要在ImageView
上畫出所需的全部內容。
我的代碼看起來像這樣。它可以進一步改進(例如移動大小或xml佈局中的顏色定義),但是您可以從中獲得創意。並沒有考慮到設備屏幕的不同尺寸和密度。
/**
* Padding between circles displaying position
*/
private static final int PADDING = 20;
/**
* Radius of circles displaying position
*/
private static final int RADIUS = 4;
// Color of the selected element's indicator
private int activeColor;
// Color of the not selected element's indicator
private int inactiveColor;
// Call this in View constructor or in activity onCreate()
Resources res = getResources();
activeColor = res.getColor(R.color.sliderActiveColor);
inactiveColor = res.getColor(R.color.sliderInactiveColor);
/**
* Draws position of current element.
* Call it on fling events.
* @param currentPosition Current element position
*/
protected void drawPosition(int currentPosition) {
// Control height
final int height = 20;
// Control width
final int bmpWidth = 200;
// Count of all elements
int count = viewFlipper.getChildCount();
// Calculate first element position on canvas
float initialPosition = bmpWidth/2 - (count - 1) * (PADDING/2 + RADIUS);
final int shift = PADDING + 2 * RADIUS;
Bitmap bitmap = Bitmap.createBitmap(bmpWidth, height, Config.ARGB_8888);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Style.FILL);
Canvas c = new Canvas(bitmap);
for (int i = 0; i < count; i++) {
// Draw circle for each element, current element with different color
if (i == currentPosition) {
paint.setColor(activeColor);
} else {
paint.setColor(inactiveColor);
}
c.drawCircle(initialPosition + i * shift, PADDING/2, RADIUS, paint);
}
// Draw on ImageView
sliderImage.setImageBitmap(bitmap);
}
而結果:
相關問題
- 1. 這種類型的控件的名稱是什麼,我如何實現它?
- 2. 這個控件的名稱是什麼?
- 3. 這個C++實現模式的名稱
- 4. Android的GUI控件名稱
- 5. GroupBox包含控件,如何獲取這些控件的名稱?
- 6. 這個動畫是如何實現的
- 7. 這個輸出是如何實現的?
- 8. 這個組件的名稱是什麼?
- 9. 如何在Android中實現這一點?
- 10. 如何在Android中實現這一點?
- 11. 這個Mac OS X控件的名稱是什麼?
- 12. 匿名函數是如何實現這個特性的?
- 13. 如何實現S3類的名稱?
- 14. android如何實現這個佈局
- 15. 什麼是名稱以及如何在android平板電腦中實現它?
- 16. Android Studio - 這個資源文件結構的竅門是如何實現的?
- 17. IAccessible實現 - 僅在控制窗口中可訪問的名稱?
- 18. 這個組件在winform VS2010中的名稱是什麼
- 19. 在dcraw的gamma_curve中實現的算法的名稱是什麼?
- 20. 在Android中實現Calendar控件
- 21. 如何在PHP中實現這個緩存控制策略?
- 22. 如何在MySQL中實現這個?
- 23. 如何在nodejs中實現這個?
- 24. 如何在MongoDB中實現這個?
- 25. 這是什麼iOS控件和如何實現它?
- 26. PHP:如何在這個結構中實現命名空間
- 27. 這個Android UI元素的名稱?
- 28. 如何在android中實現這個滑動窗格UI?
- 29. 我該如何在Android中實現這個視圖
- 30. 如何在Android中實現這個圖像堆棧效果?
,看起來像一些應用程序的窗口小部件,並可能不是一個單一的控制。 – jkhouw1 2011-05-18 11:26:47
它是做什麼的?我甚至無法識別它。 – Blundell 2011-05-18 11:55:53
我認爲它是在每個Android設備默認情況下。它會在用戶從一個屏幕滑動到另一個屏幕時自動顯示,以查看更多(已安裝應用程序的圖標)圖標。 – Sourav 2011-05-18 12:30:04