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 6578067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:43:22+00:00 2026-05-25T15:43:22+00:00

I have followed this tutorial ( http://stuffthathappens.com/blog/2008/11/13/android-animation-101/ ) and have a beautiful rotating text

  • 0

I have followed this tutorial (http://stuffthathappens.com/blog/2008/11/13/android-animation-101/) and have a beautiful rotating text being drawn onto a canvas. Everything works perfectly when my main activity uses

setContentView(new SplashScreenAnimation(this));

Here is SplashScreenAnimation:

public class SplashScreenAnimation extends View {
    private static final String QUOTE = "Nobody uses Java anymore. It's this big heavyweight ball and chain.";

    private Animation anim;

    public SplashScreenAnimation(Context context) {
        super(context);
    }

    private void createAnim(Canvas canvas) {
        anim = new RotateAnimation(0, 360, canvas.getWidth() / 2, canvas
                .getHeight() / 2);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);
        anim.setDuration(10000L);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());

        startAnimation(anim);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        // Creates the animation the first time
        if (anim == null) {
            createAnim(canvas);
        }

        Path circle = new Path();

        int centerX = canvas.getWidth() / 2;
        int centerY = canvas.getHeight() / 2;
        int r = Math.min(centerX, centerY);

        circle.addCircle(centerX, centerY, r, Direction.CW);
        Paint paint = new Paint();
        paint.setColor(Color.BLUE);
        paint.setTextSize(30);
        paint.setAntiAlias(true);

        canvas.drawTextOnPath(QUOTE, circle, 0, 30, paint);
    }
}

However I want to combine this animated text and have two buttons underneath it so I have a RelativeLayout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout1"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent" android:background="@drawable/splash_screen">
 <LinearLayout android:orientation="vertical"
  android:layout_height="wrap_content" android:layout_width="fill_parent"
  android:layout_alignParentBottom="true" android:id="@+id/bottomLinearLayout">
  <Button android:layout_gravity="center_horizontal" android:id="@+id/playButton"
   android:text="Button" android:layout_height="wrap_content"
   android:layout_width="wrap_content"></Button>
  <Button android:layout_height="wrap_content"
   android:layout_width="wrap_content" android:id="@+id/optionsButton"
   android:text="Button" android:layout_gravity="center_horizontal"
   android:layout_marginBottom="30sp"></Button>
 </LinearLayout>


 <LinearLayout android:id="@+id/topLinearLayout"
  android:orientation="vertical" android:layout_height="wrap_content"
  android:layout_alignParentTop="true" android:layout_width="fill_parent">
 </LinearLayout>

</RelativeLayout>

How can I add this custom view to the LinearLayout above? (topLinearLayout – it’s the last one)

I’ve tried a lot of different things, and I keep ending up with force closes.

This sort of approach has been mainly what I’ve tried. I’ve tried inflating it, etc.

LinearLayout item = (LinearLayout)findViewById(R.id.topLinearLayout);
SplashScreenAnimation child = new SplashScreenAnimation(this);
item.addView(child);

I added entire SplashScreenAnimation class code:

((LinearLayout) findViewById(R.id.topLinearLayout)).addView(new SplashScreenAnimation(this))

It works!!

Why won’t the other methods of adding it manually work? Has it something to do with the fact the animation needs to start via onDraw?

  • 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-05-25T15:43:23+00:00Added an answer on May 25, 2026 at 3:43 pm

    Try this line to add the view:

    ((LinearLayout) findViewById(R.id.topLinearLayout)).addView(new SplashScreenAnimation(this))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed this tutorial and added iAd to my app: http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/ But the
I have followed this tutorial to get my ListView populating data -- http://android.amberfog.com/?p=296 .
I followed this tutorial : http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ and I got the alert 'Text messaging is
I have followed this tutorial: http://www.phpjabbers.com/how-to-make-a-php-calendar-php26-6.html#comments to make a very basic calendar. My aim
I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
I have followed this tutorial http://blogs.wrox.com/article/creating-a-simple-ipad-application-table-view/ (creating a uitableview and populating it). I want
I have followed this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, and after seing that I had issues
I have followed this tutorial to create the first azure application http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_IntroToWindowsAzureLabVS2010 Because after
http://www.devx.com/wireless/Article/39101/0/page/2 I have followed this tutorial and got it to work and everything. now
I'm using Eclipse 3.5.2 and when I followed the steps on this tutorial( http://developer.android.com/guide/developing/tools/adt.html

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.