Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:59:56+00:00 2026-06-04T23:59:56+00:00

I need to create a circle that rotates and contains data for my application.

  • 0

I need to create a circle that rotates and contains data for my application. Should I create a customized object for my application or should I make a in-application widget?

While on the topic, how do you refer to a widget within an application instead of a stand alone widget for the android desktop?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:59:59+00:00Added an answer on June 4, 2026 at 11:59 pm

    This is a rotatable LinearLayout that you can put everything in it and you can rotate it by degree if you customize it. use rotate() method to rotate it and…

    enjoy! 😉

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Matrix;
    import android.util.AttributeSet;
    import android.view.MotionEvent;
    import android.widget.LinearLayout;
    
    public class RotateLinearLayout extends LinearLayout {
    
        private Matrix mForward = new Matrix();
        private Matrix mReverse = new Matrix();
        private float[] mTemp = new float[2];
        private float degree = 0;
    
        public RotateLinearLayout(Context context) {
            super(context);
        }
    
        public RotateLinearLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected void dispatchDraw(Canvas canvas) {
    
            try {
                if (degree == 0) {
                    super.dispatchDraw(canvas);
                    return;
                }
                canvas.rotate(degree, getWidth() / 2, getHeight() / 2);
    
                mForward = canvas.getMatrix();
                mForward.invert(mReverse);
                canvas.save();
                canvas.setMatrix(mForward); // This is the matrix we need to use for
                                            // proper positioning of touch events
    
                super.dispatchDraw(canvas);
                canvas.restore();
                invalidate();
            } catch (Exception e) {
    
            }
    
        }
    
        @Override
        public boolean dispatchTouchEvent(MotionEvent event) {
            if (degree == 0) {
                return super.dispatchTouchEvent(event);
            }
            // final float[] temp = mTemp;
            // temp[0] = event.getX();
            // temp[1] = event.getY();
            // mReverse.mapPoints(temp);
            // event.setLocation(temp[0], temp[1]);
            event.setLocation(getWidth() - event.getX(), getHeight() - event.getY());
            return super.dispatchTouchEvent(event);
        }
    
        public void rotate() {
            if (degree == 0) {
                degree = 180;
            } else {
                degree = 0;
            }
        }
    
    }
    

    Update:

    add this code to your xml layout and put your Views like ImageView or another LinearLayout in it :

    <org.mabna.order.ui.RotateLinearLayout  android:id="@+id/llParent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="horizontal" >
    
    
    
    <ImageView
                            android:id="@+id/myImage"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="5dip"
                            android:src="@drawable/main01" />
    
    </org.mabna.order.ui.RotateLinearLayout>
    

    in onCreate() method:

    llParent = (RotateLinearLayout) this.findViewById(R.id.llParent);
    

    in onClickListener of a button:

    protected void btnRotate_onClick() {
            llParent.rotate();
        }
    

    Update2:

    You can use an animation for rotation before real rotation (llParent.rotate();). it needs an animation layout like rotate_dialog.xml:

    <?xml version="1.0" encoding="utf-8"?>
    
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000" android:fromDegrees="-180" android:toDegrees="0"
        android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" />
    

    and in your code:

    protected void btnRotate_onClick() {
            // rotate 
            Animation rotateAnimation = AnimationUtils.loadAnimation(this,
                    R.anim.rotate_dialog);
            llParent.startAnimation(rotateAnimation);
            llParent.rotate();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a range-graded circle proportional map, i.e., a map that has
I want to create custom button and I need it to be circle. How
I need to create a div with rounded corners containing an image that can
Many times I found out that I need a software to create simple educational
I have a need for a personal command-line tool that should take the name
So I'm working in Python trying to create a ShapeSet instance that contains a
I need to create a circle of regularly spaced doors around a reference point
I have a circle on the a map that I need to update, here
I am using the RGraph and I need to create circles with a gradients,
I need create custom tabbar with super class UITabBarController. But i don,t know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.