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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:08:18+00:00 2026-05-29T12:08:18+00:00

I have a FrameLayout in which I have placed two identical TextViews. I want

  • 0

I have a FrameLayout in which I have placed two identical TextViews.
I want to be able to translate the first view to the left (which I have done and is working like a charm). However I want to be able to click the TextView underneath it to perform an action.

When I try to click the bottom TextView, the top TextView gets clicked again instead. I have a feeling this is because the way animations are rendered and the change in actual x,y position doesn’t take effect.

This is what I have so far.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:text="@string/hello" 
        android:id="@+id/unbutt"
        android:gravity="right|center_vertical"
        />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:text="@string/hello" 
        android:id="@+id/butt" />

</FrameLayout>

The code:

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;

public class Main extends Activity implements AnimationListener, OnClickListener
{
    /** Called when the activity is first created. */

    private class BottomViewClick implements OnClickListener
{

    @Override
    public void onClick(View v) {
        Toast.makeText(v.getContext(), "Second Click", 5).show();
    }

}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TextView tv = (TextView)findViewById(R.id.butt); 
    tv.setBackgroundColor(0xffb71700);
    tv.setOnClickListener(this);

    TextView tv2 = (TextView)findViewById(R.id.unbutt); 
    tv2.setBackgroundColor(0xffb700ff);
    tv2.setOnClickListener(new BottomViewClick());

}

    private boolean revealed = false;

    @Override
    public void onClick(View v) {
        Animation a ;
        if(!revealed)
            a = new TranslateAnimation(0f, -200f, 0f, 0f);
        else
            a = new TranslateAnimation(-200f, 0f, 0f, 0f);
        a.setDuration(500);
        a.setFillAfter(true);
        a.setAnimationListener(this);
        v.startAnimation(a);
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        if(revealed)
            revealed = false;
        else
            revealed = true;
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }

    @Override
    public void onAnimationStart(Animation animation) {
    }
}
  • 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-29T12:08:20+00:00Added an answer on May 29, 2026 at 12:08 pm

    You have ICS in the tag, so I assume that’s what your target is. In that case, the Animation objects you’re using are essentially deprecated in favor of the Animator class. The old way of doing it only moves the visual location of the View while the physical location remains the same. You would have to move it yourself by manipulating the margins of the view. Using an ObjectAnimator on the other hand allows you to physically move the object along with it’s visual component.

    http://android-developers.blogspot.com/2011/05/introducing-viewpropertyanimator.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FrameLayout view which contains one (MapView-like) control and some additional buttons
Ho I have two list view on a frame layout. I want one overlay
I have used FrameLayout in which I have used two LinearLayouts. The second one
I have a FrameLayout in which I have 2 controls: - a custom view
I have a group of FrameLayout which I want to be checkable/selectable, That is,
I have a custom FrameLayout class which does some custom drawing on the OnSizeChanged
I have an application, which has a Spinner that I want populated with some
I have activity_main which is default layout in my activity, there i have framelayout
I have a simple combination of one ImageView and two TextViews over it. I
I have a FrameLayout which has a ScrollView as the only child. During runtime

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.