Button click is not working after Animation - android

I have two button in one LinearLayout and inside this LinearLayout i have two button. When i animate LinearLayout then working fine but when tried to click on Button which is inside LinearLayout, click of button is not working.
I already searched a lot but not able get rid this issue.
Below code to animate LinearLayout
an = new RotateAnimation(angleRightHead, getRotateAngleRightEdgehead (), Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0.33f);
an.setRepeatMode(Animation.REVERSE);
an.setDuration(1000);
an.setRepeatCount(0);
an.setFillAfter(true);
an.setFillEnabled(true);
head_neck_ll.startAnimation(an);
and this code of XML
<LinearLayout
android:id="#+id/head_neck_idll"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/head"
android:layout_width="70dp"
android:layout_height="20dp"
android:background="#drawable/roundcorner"
android:clickable="true"
android:onClick="clickhander" />
<!-- </RelativeLayout> -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:padding="3dp"
android:layout_height="16dp" >
<Button
android:id="#+id/lumber"
android:layout_width="49dp"
android:layout_marginLeft="3dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_marginBottom="-10dp"
android:background="#drawable/roundcorner"
android:clickable="true"
android:onClick="clickhander" />
</RelativeLayout>
<Button
android:id="#+id/backupper"
android:layout_width="80dp"
android:layout_height="20dp"
android:background="#drawable/roundcorner"
android:clickable="true"
android:onClick="clickhander" />
</LinearLayout>
</LinearLayout>
and code for onClickListener
public void clickhander(View v){
if(v.getId() == R.id.head){
textv = head;
v1right = mapRight.get(head);
v1right = mapLeft.get(head);
head.setBackgroundResource(R.drawable.clickroundcorner);
lumber.setBackgroundResource(R.drawable.roundcorner);
backupper.setBackgroundResource(R.drawable.roundcorner);
backlower.setBackgroundResource(R.drawable.roundcorner);
legside.setBackgroundResource(R.drawable.roundcorner);
angle =0;
} else if(v.getId() == R.id.backupper){
textv = backupper;
v1right = mapRight.get(backupper);
v1right = mapLeft.get(backupper);
backupper.setBackgroundResource(R.drawable.clickroundcorner);
head.setBackgroundResource(R.drawable.roundcorner);
lumber.setBackgroundResource(R.drawable.roundcorner);
backlower.setBackgroundResource(R.drawable.roundcorner);
legside.setBackgroundResource(R.drawable.roundcorner);
angle =0;
}
}
Check the image:
Note: 1 and 2 both are in same layout. I want click listener on each with layout animation
Your help would be appreciated.

Yes, this is normal behavior. This is because animation just rerenders View's pixels, but it's position on the display remains the same.
If you want to relocate your View to the place where your animation ends, you need to call View.layout() method and pass these 4 parameters, which describe Views new position on its layout.
Keep in mind that View.layout() gets params relative to `View's parent.

Related

Android design game card UI

I need help with the design of my card game.
I having a Vector of cards (player cards), each item appers in ImageView (Already done and working).
private Vector<Card> myCards;
I having a LinearLayout that holding 5 imageView's.
<LinearLayout
android:id="#+id/myCardsLayout"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingBottom="10dip">
<ImageView
android:id="#+id/my_card_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="goToMainMenu"
/>
<ImageView
android:id="#+id/my_card_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="goToMainMenu"
/>
<ImageView
android:id="#+id/my_card_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="goToMainMenu"
/>
<ImageView
android:id="#+id/my_card_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="goToMainMenu"
/>
<ImageView
android:id="#+id/my_card_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="goToMainMenu"
/>
</LinearLayout>
I want to choose the cards that i want to drop by click on the card, And that the player will see this by jumping the card slightly up (or another recommended way).
I will implement that on android:onClick function (goToMainMenu is a temporary statement).
Any idea ? Thanks!
UPDATE1
public void myCard1OnClick(View view) {
view.setSelected(true);
if(view.isSelected()) {
int y = view.getTop();
view.setTop(y - 30);
}
else{
int y = view.getTop();
view.setTop(y + 30);
}
}
You can make an onclick function on cards that moves and give them a function that takes their x and y cordinates and then you just inflate y to move up.
try to use setX() and setY() view properties to move across a space.
And about the issue of moving the card and after that it get back to its original position, maybe its because the set selected its not working, and then enters to the else statement.

How to do continuous animation in android?

I want my image buttons to start from top of the screen and reach end of screen followed by another image button behind it and this goes on forever like white strips on a road. As one button reaches end of screen the portion which is not visible must be visible at the top of the screen and this should be applicable for each button.
See the image for the last image button for clear view.
Screenshot
This is the code for my XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.ash432.itguesses.options"
android:background="#040404">
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im1"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:background="#f9f6f6"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layoutAnimation="#anim/layout_anim"
/>
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im2"
android:background="#f9f6f6"
android:layout_marginTop="26dp"
android:layout_below="#+id/im1"
android:layout_alignLeft="#+id/im1"
android:layout_alignStart="#+id/im1" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im3"
android:background="#f9f6f6"
android:layout_marginTop="26dp"
android:layout_below="#+id/im2"
android:layout_alignLeft="#+id/im2"
android:layout_alignStart="#+id/im2" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im4"
android:background="#ffffff"
android:layout_marginTop="26dp"
android:layout_below="#+id/im3"
android:layout_alignLeft="#+id/im3"
android:layout_alignStart="#+id/im3" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im5"
android:background="#ffffff"
android:layout_marginTop="26dp"
android:layout_below="#+id/im4"
android:layout_alignLeft="#+id/im4"
android:layout_alignStart="#+id/im4" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im6"
android:background="#ffffff"
android:layout_marginTop="26dp"
android:layout_below="#+id/im5"
android:layout_alignLeft="#+id/im5"
android:layout_alignStart="#+id/im5" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im7"
android:background="#ffffff"
android:layout_marginTop="26dp"
android:layout_below="#+id/im6"
android:layout_alignLeft="#+id/im6"
android:layout_alignStart="#+id/im6" />
<ImageButton
android:layout_width="5dp"
android:layout_height="40dp"
android:id="#+id/im8"
android:background="#ffffff"
android:layout_marginTop="26dp"
android:layout_below="#+id/im7"
android:layout_alignLeft="#+id/im7"
android:layout_alignStart="#+id/im7" />
And here is the java code
public class options extends AppCompatActivity
{
private ImageButton im1,im2,im3,im4,im5,im6,im7,im8;
private Animation mAnimation;
//private Button b;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_options);
im1 = (ImageButton)findViewById(R.id.im1);
im2 = (ImageButton)findViewById(R.id.im2);
im3 = (ImageButton)findViewById(R.id.im3);
im4 = (ImageButton)findViewById(R.id.im4);
im5 = (ImageButton)findViewById(R.id.im5);
im6 = (ImageButton)findViewById(R.id.im6);
im7 = (ImageButton)findViewById(R.id.im7);
im8 = (ImageButton)findViewById(R.id.im8);
mAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
TranslateAnimation.RELATIVE_TO_PARENT, 1.0f);
mAnimation.setDuration(2000);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.INFINITE);
mAnimation.setInterpolator(new LinearInterpolator());
mAnimation.getStartTime();
im1.setAnimation(mAnimation);
im2.setAnimation(mAnimation);
im3.setAnimation(mAnimation);
im4.setAnimation(mAnimation);
im5.setAnimation(mAnimation);
im6.setAnimation(mAnimation);
im7.setAnimation(mAnimation);
im8.setAnimation(mAnimation);
}
}
UPDATE-
For those who cannot understand the question properly.
1)At first I want nothing on the screen just the background.
2)Then after sometime a white strip should be seen coming from top of the screen.
3)Then when it has fully come, after some time second white strip should be seen coming.
4)Same procedure for all the Eight Image Buttons.
5)Now when the first image button reaches the bottom of the screen . Its size should be decreasing while at the top of the screen its size should be increasing.Similarly for all the buttons when they reach the bottom of the screen
6)The gap between the strips should be constant.
Here is the image showing the steps-
Image
I hope I have made my question clear.
Your question is not very clear but I assume you want to recycle those white stripes.
You should use RecyclerView for this.
compile 'com.android.support:recyclerview-v7:23.1.1'
in your XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.ash432.itguesses.options"
android:background="#040404">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
Then create another xml layout for those stripes and connect them using an Adapter.
Edit:
RecyclerView is an advanced version of ListView with better performance.It's a view, previously used to display data for a specific adapter position may be placed in a cache for later reuse to display the same type of data again later.
Adapter is a subclass of RecyclerView.Adapter responsible for providing views that represent items in a data set.
here is a great source that you can learn how to implement recyclerview.

Android- adding view to layout causing layout to be in front of ActionBar

I have a view in which I'm creating a PopupWindow. In this PopupWindow, I have a text box (EditText). When clicking to edit the text, the keyboard opens and the whole view goes up, but the top of the view goes under the action bar view smoothly. So far so good.
I now have added an empty GridView without any further configuration to the PopupWindow, and now the same scenario happens but the whole top part of the view goes on top of the action bar view and not smooth (the popup becomes a mess, when keyboard disappears the popup location changes for couple of seconds and there are "leftovers" from the keyboard for a second). It also happens with ListView.
I want the top part of the view to go under the 'ActionBar` smoothly, as it should.
Any ideas?
UPDATE: By adding the GridView programatically I partially solved it on a couple of devices, but on some devices it's still happens.
Displaying the popupwindow:
pView=inflater.inflate(R.layout.activity_packbuild, (ViewGroup)mainActivity.findViewById(R.layout.activity_main));
pw = new PopupWindow(
pView,
ma.f.getView().getMeasuredWidth(),
ma.f.getView().getMeasuredHeight(),
true);
pw.showAtLocation(mainActivity.getWindow().getDecorView().findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
GOOD:
BAD:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lID">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rID"
android:background="#drawable/back5">
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="#+id/mImageView"
android:background="#drawable/com_facebook_picker_default_separator_color"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_below="#+id/mImageView"
android:layout_marginTop="22dp"
android:layout_toRightOf="#+id/lButton"
android:layout_toLeftOf="#+id/rButton" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="#+id/imageViewRR"
android:background="#drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="#+id/mImageView"
android:layout_toRightOf="#+id/mImageView"
android:layout_marginLeft="20dp" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="#+id/imageViewLL"
android:background="#drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="#+id/mImageView"
android:layout_toLeftOf="#+id/mImageView"
android:layout_marginRight="20dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/lButton"
android:layout_below="#+id/editText"
android:layout_alignLeft="#+id/imageViewLL"
android:layout_alignStart="#+id/imageViewLL" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/rButton"
android:layout_alignTop="#+id/lButton"
android:layout_alignRight="#+id/imageViewRR"
android:layout_alignEnd="#+id/imageViewRR"
android:layout_marginTop="5dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/picButton"
android:layout_alignTop="#+id/galleryButton"
android:layout_alignLeft="#+id/editText"
android:layout_alignStart="#+id/editText"
android:background="#drawable/camera2" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/videoButton"
android:background="#drawable/video"
android:layout_alignTop="#+id/galleryButton"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="#+id/imageViewR"
android:background="#drawable/com_facebook_picker_default_separator_color"
android:layout_above="#+id/editText"
android:layout_alignRight="#+id/sendButon"
android:layout_alignEnd="#+id/sendButon" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="#+id/imageViewL"
android:background="#drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="#+id/mImageView"
android:layout_alignLeft="#+id/editText" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/galleryButton"
android:background="#drawable/gallery"
android:layout_alignTop="#+id/rButton"
android:layout_alignRight="#+id/imageViewR" />
<ImageButton
android:layout_width="100px"
android:layout_height="100px"
android:id="#+id/toButton"
android:layout_above="#+id/imageViewR"
android:layout_alignLeft="#+id/picButton"
android:layout_alignStart="#+id/imageViewL"
android:background="#drawable/fbfriends2"
android:layout_alignRight="#+id/imageViewLL"
android:layout_alignEnd="#+id/imageViewLL"
android:layout_marginBottom="20dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/sendButon"
android:background="#drawable/go"
android:layout_alignTop="#+id/toButton"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/plusButtonL"
android:background="#drawable/plusp"
android:layout_alignTop="#+id/videoButton"
android:layout_toRightOf="#+id/imageViewLL" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/minusButtonR"
android:background="#drawable/minusp"
android:layout_alignTop="#+id/videoButton"
android:layout_toLeftOf="#+id/imageViewRR" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/plusButton"
android:background="#drawable/plusp"
android:layout_alignTop="#+id/videoButton"
android:layout_centerHorizontal="true" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/minusButton"
android:background="#drawable/minusp"
android:layout_alignTop="#+id/videoButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
</RelativeLayout>
I'm adding the GridView programmatically:
gv=new GridView(ma);
List<Student> hhh=new ArrayList<Student>();
if (FriendPickerApplication.selectedUsers!=null) {
if (FriendPickerApplication.selectedUsers.size() > 0) {
for (GraphUser gu : FriendPickerApplication.selectedUsers) {
hhh.add(new Student("name", gu.getId()));
}
}
}
StudentAdapter sta=new StudentAdapter(ma,hhh);
//gv=(GridView)pView.findViewById(R.id.gridView2);
gv.setVisibility(View.VISIBLE);
MainActivity.wantedPicSize=ma.screenWidth/12; //6
int wantedSize=MainActivity.wantedPicSize+2; //10
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
relativeParams.addRule(RelativeLayout.LEFT_OF, btnSend.getId());
relativeParams.addRule(RelativeLayout.RIGHT_OF,picFriends.getId());
relativeParams.addRule(RelativeLayout.ALIGN_TOP, picFriends.getId());
relativeParams.addRule(RelativeLayout.ALIGN_BOTTOM, picFriends.getId());
gv.setLayoutParams(relativeParams);
gv.setPadding(5,0,5,0);
((RelativeLayout)pView.findViewById(R.id.rID)).addView(gv);
ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);//gv.getLayoutParams();
relativeParams.height = wantedSize+(int)(wantedSize/5); //this is in pixels
relativeParams.width = (int)(ma.screenWidth/3.0);//gv.getLayoutParams().width; //(int)( ( ((ma.screenWidth*3)/4)/wantedSize )*wantedSize );
gv.setColumnWidth(wantedSize); //+width betwen profiles
gv.setVerticalSpacing(5);
//gv.setNumColumns((int)((screenWidth/2)/100));
gv.setNumColumns((relativeParams.width/wantedSize));
System.out.print("COLUMNSSSSSSSSSS- "+(relativeParams.width/wantedSize));
gv.setLayoutParams(relativeParams);
gv.setVisibility(View.VISIBLE);
gv.setAdapter(sta);
Your problem here is the popup window.
There is no way to make it go under the actionbar since the actionbar is displayed in another window that is below the new window you are creating. moreover using a popup window for that complex layout is never going to perform efficiently. Have you thought of wrapping your map and the layout you are putting in the popup window in a custom layout? That would probably be the easier solution
I agree with the answer posted by Pasquale Anatriello. Though u can
You can try different methods :
mPopUpWindow.showAsDropDown(anchor);
mPopUpWindow.showAsDropDown(anchor, xoff, yoff);
mPopUpWindow.showAtLocation(parent, gravity, x, y);
I suggest you should let popUp draw only after Action Bar, take y axis offset and gravity top, say: yOffset is Equivalent to actionbar height, if you have action bar ~ height x 10% of device height , [layout_weight = 1.0].
Even if it didn't work out create a custom View [say Linear Layout] that appears and disappears and acts like popup a window and give u flexibility as u want,handle clicks by yourself, make it like a toggle, see code for animation::
Animation fadeInAnimation = AnimationUtils.loadAnimation(v.getContext(), android.R.anim.fade_in);
fadeInAnimation.setDuration(10);
v.startAnimation(fadeInAnimation);
Animation fadeOutAnimation = AnimationUtils.loadAnimation(v.getContext(), android.R.anim.fade_out);
fadeOutAnimation.setDuration(10);
v.startAnimation(fadeOutAnimation);

Align Android seekbar with thumb

I'm trying to align the seekbar to the top of a view, but i can't center it with the thumb.
Is there some kind of "alignCenter" with the RelativeLayout children.
Here's a sample of my xml code :
<RelativeLayout
android:id="#+id/rl_fragment_audio_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/black_transparent"
android:padding="5dp"
android:visibility="gone" >
<TextView
android:id="#+id/tv_fragment_audio_begin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="#color/white" />
<TextView
android:id="#+id/tv_fragment_audio_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_fragment_audio_play"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="#drawable/btn_play"
android:visibility="gone" />
</RelativeLayout>
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_above="#id/rl_fragment_audio_player" />
For example, Google Play Music does it.
As you said the height of your seekbar might vary, unless you specify it different. Here is how you can make sure it fits all, always.
android:layout_above="#id/rl_fragment_audio_player"
is setting your seekbar bottom above rl_fragment_audio_player top. There is no direct method to specify centerAlignWith but I would remove the space it occupies within it's parent. To know the height of the seekbar you must wait until the global layout has changed. This code should be placed inside your onCreateView
sb = (SeekBar) rootView.findViewById(R.id.sb_fragment_audio);
sb.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener(){
#Override
public void onGlobalLayout() {
sb.getViewTreeObserver().removeOnGlobalLayoutListener(this);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sb.getLayoutParams();
params.setMargins(0, - sb.getHeight() / 2, 0, - sb.getHeight() / 2);
sb.setLayoutParams(params);
// I suggest you set the seekbar visible after this so that it won't jump
}
});
The last view in the xml will be in the front. Therefore make sure your seekbar is added after the the other views. Like this
<RelativeLayout
android:id="#+id/rl_fragment_audio_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
// your bottom panel
</RelativeLayout>
<View
android:id="#+id/image_above"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/rl_fragment_audio_player" />
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/image_above" />
Have you tried adding a negative margin to the seekbar?
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginBottom="-15dp"
android:layout_above="#id/rl_fragment_audio_player" />

How to make my layout to move completely left of screen like an animation in android?

I have a Relative Layout in my xml,I want to move that view to complete left like an animation(upto screen left). I want the complete inner layout to move like an animation upto screen end
I want to put animation for Relative layout with id="center"
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/img_1"
android:layout_centerInParent="true"
android:id="#+id/cartoon_image">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/play_btn"
android:orientation="horizontal"
android:layout_centerInParent="true"
android:id="#+id/play_btn"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:gravity="center"
android:background="#drawable/circle"
android:id="#+id/center">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/like_small"
android:id="#+id/like_image_centre"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_below="#+id/like_image_centre"
android:text="36"
android:textSize="25dp"
android:textColor="#DF013A"
android:id="#+id/likes_count_centre"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Please help in solving this issue
try this code in onCreate of your activity
by changing this functionTranslateAnimation(fromX,toX,fromY,toY) ,you can set the Animation you want to move the layout.
RelativeLayout mLayout = (RelativeLayout) findViewById(R.layout.center);
TranslateAnimation anim=new TranslateAnimation(0,80,0,0);
anim.setDuration(1500);
anim.setRepeatCount(Animation.INFINITE);
// anim.setRepeatMode(Animation.INFINITE);
anim.setRepeatMode(Animation.REVERSE);
mLayout.setAnimation(anim);

Categories

Resources