문제

Today I had my first time with Android 4.2, and I noticed how the home screen automatically repositions widgets as you drag them:

I recently worked on a similar code for our project, and I have to admit its performance is much worse. My algorithm is really stupid, and I'm looking for better alternatives. This is the closest one I've found yet, but I haven't tested it yet.

From my understanding, this is related to bin packing, but bin packing algorithms focus on putting rectangles as close to each other as possible, while Android implementation focuses on making as few changes as possible from the initial configuration, and thus is aesthetically pleasing.

Because Android is open source, I hoped to learn from their code, but I can't find anything related to laying out rectangles in android.appwidget. What is the right place to look at?

도움이 되었습니까?

해결책

I'm not 100% sure but it looks like CellLayout.java from Launcher2 is reponsible for this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top