开发者

How to create Curve layout in Android?

开发者 https://www.devze.com 2023-03-23 11:20 出处:网络
I want to create an Cur开发者_如何转开发ve layout like Sen want here How to create this layout?

I want to create an Cur开发者_如何转开发ve layout like Sen want here How to create this layout?

Here at place of bubble I need button's, here want to move layout like gallery?

pls suggest me. Thanks


See this answer to the question layout with buttons in a circle. It provides a method to plot XY coordinates in your layout.

EDIT 7/28/2011: The second answer to layout with buttons in a circle did not include XML. @Shubh asked for it in the comments, below, so I put this together:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <FrameLayout 
        android:layout_width="130dp"
        android:layout_height="85dp"
        android:background="#FFCC0000">
        <Button 
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="right|bottom"
        />
    </FrameLayout>  
    <FrameLayout 
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#FFCCCC00">
        <Button 
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="right|bottom"
        />
    </FrameLayout>  
    <FrameLayout 
        android:layout_width="85dp"
        android:layout_height="130dp">
        <Button 
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="right|bottom"
        />
    </FrameLayout>  
</RelativeLayout>

How to create Curve layout in Android?


Ok, for what its worth, my approach would be to create a custom layout, probably extending an AbsoluteLayout. You would have to query for the screen dimensions and then you could create a Path or EllipticCurve within the layout which best fits the screen dimensions. Next you could determine where on the curve (or offset from the curve) you wish to position graphics or buttons. You would also have to create a custom gesture detector by extending SimpleOnGesturreListener so that the fling action did what you want it to do e.g. do an animation on one or more or all of the objects on the curve. This is obviously just a starting point but it should get you started and once you try and run it, you will see issues or behaviours that need adjusting. Good luck with it.

Edit: You could make it more generic by being able to pass in a shape e.g. curve, circle etc and then getting it to layout your buttons along the path of the shape.

0

精彩评论

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

关注公众号