开发者

ImageViews in circle

I want 开发者_运维百科to put 20 ImageView objects in LinearLayout rotated so that they form a circle. Is this possible and how, and is this the right approach for creating circular layout of ImageView objects?

Thanks


I'm not conversant with the android API, but it doesn't look like you can bend a LinearLayout into a circle. Rotating it should only change it's angle (horizontal versus vertical versus diagonal).

Probably, you're going to want to do something based off of an AbsoluteLayout or RelativeLayout, then perform geometry-related math to find out the positions the various elements need to be at.

Ideally, for future re-use, you should actually create a new CircularLayout that could be applied to containers. You want the API to require a List of some sort of the elements (plus optionally padding), then have the layout perform the necessary math.


LinearLayout can only present child elements either vertical or horizontal. You can position the ImageViews to form a circle if you use a RelativeLayout, but rotating them will include lots of calculations


consider using the canvas and draw paint functions


Try this:

Your XML

<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/myImageontoolbar"
android:padding="5dp"
android:layout_width="10mm"
android:layout_height="10mm"
android:layout_gravity="left"
app:srcCompat="@android:drawable/sym_def_app_icon" />

Your Gradle

compile 'de.hdodenhof:circleimageview:2.1.0'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜