Jump to content
  • Advertisement
Sign in to follow this  
grumpyOldDude

How to let user pick and drop, and resize buttons

This topic is 553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the UI of my Puzzle Game I hit a problem .... 

In Android xml layout, how do I add code functionalities that allow the app user to resize buttons (or other form widgets)?

 

Also what code in xml layout allows a user to pick a button from the menu and drop it at a position on the 'surface' they click? The pick and drop would be done first and then the resizing of the buttons (or other form widget) next

 

Though the xml  code for allowing user to resize is the more important and the more pressing problem for now, but i will also appreciate solution for xml code which allows users to pick and drop

 

Initially it seemed like this xml code would be easy to find on the internet and I've been googling this for long but most of "user resizable code" I find are related to appwidget-provider class which is a different thing entirely. Other googling results don't threat it programmatically (xml coding) even though that was a key word in the search

 

thnx

Share this post


Link to post
Share on other sites
Advertisement
Maybe I'm misunderstanding the problem but this doesn't sound like something you'd do with xml alone. You could listen for a button interaction with setOnClickListener(), track movement with setOnTouchListener() then move the button with setLayoutParams(). Maybe there are other ways of doing this though?

Share this post


Link to post
Share on other sites

I've found solution that allows coding which lets the user/player perform drag and drop on menu widgets (or just buttons).     Android has the APIs 

 

setOnDragListener( ... ), onDrag(View v, DragEvent event), DragEvent.ACTION_DROP, and base class OnDragListener

 

these allows you to code drag and drop for the user

 

But i still can't find solution for the APIs(or code example) to allow user to resize buttons. Any help on this will be appreciated

Share this post


Link to post
Share on other sites

Many thanks @[member='Nyssa']

I think I missed that because I relied so much on the key words 'user resize' among others while googling. Scaling or gestures never occurred to me

 

I'm also looking to see if this allows users to make asymmetric scaling along x and y of a generic widget (button)  

 

A quick look through ... i'm not yet sure it allows that. Do you know?

Share this post


Link to post
Share on other sites
Glad it helped. In regards to the asymmetrical scaling... In the following code grabbed from that link mScaleFactor is x and y scale. So you could have an x only and y only scale mode where you just keep the scale set to the previous scale for the other axis?
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.save();
    canvas.scale(mScaleFactor, mScaleFactor);
    ...
    // onDraw() code goes here
    ...
    canvas.restore();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!