Android, animation, How to sliding in and out a layout from screen?

删除回忆录丶 提交于 2019-12-04 21:08:46

Answer to second question. Try changing your layout as below:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <FrameLayout
        android:id="@+id/camera_preview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <RelativeLayout
        android:id="@+id/rlMenu"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/btn_hide"
                android:layout_width="40dip"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dip"
                android:layout_marginTop="10dip"
                android:contentDescription="@string/menu_contentdescription"
                android:scaleType="fitXY"
                android:src="@drawable/btn_record_hide" />

            <ImageView
                android:id="@+id/btn_record"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dip"
                android:layout_toRightOf="@id/btn_hide"
                android:contentDescription="@string/menu_contentdescription"
                android:src="@drawable/btn_record_start" />

            <ImageView
                android:id="@+id/btn_stop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dip"
                android:layout_marginTop="10dip"
                android:layout_toRightOf="@id/btn_record"
                android:clickable="false"
                android:contentDescription="@string/menu_contentdescription"
                android:src="@drawable/btn_record_stop" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/btn_done"
                style="@style/simpletopic.bold"
                android:layout_width="wrap_content"
                android:layout_height="50dip"
                android:layout_alignParentRight="true"
                android:background="@drawable/btn_record_done"
                android:paddingLeft="15dip"
                android:text="@string/Record_btn" />
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

I had a similar situations with a custum MapView.

I think this will work out if you use frame layout.Add two frames and add the pictures to the frame.Alternatively adding the animation to the two frames and making it play will make this work out.I think this will work and give you what you wanted.A small piece of code is shown below hope this will help you a lil bit.

if (imagesetflag == true) {
                Right_to_left_in = AnimationUtils.loadAnimation(this,
                        R.anim.right_to_left_in);
                Right_to_left_out = AnimationUtils.loadAnimation(this,
                        R.anim.right_to_left_out);
                left_to_Right_in = AnimationUtils.loadAnimation(this,
                        R.anim.left_to_right_in);
                Left_to_Right_out = AnimationUtils.loadAnimation(this,
                        R.anim.left_to_right_out);

                frame1.setImageBitmapReset(decryptedimage, 0, true);

                frame1.bringToFront();
                frame1.setVisibility(View.VISIBLE);
                frame2.setVisibility(View.INVISIBLE);
                frame1.setAnimation(Right_to_left_in);
                frame2.setAnimation(Right_to_left_out);                                     

            } else {
                Right_to_left_in = AnimationUtils.loadAnimation(this,
                        R.anim.right_to_left_in);
                Right_to_left_out = AnimationUtils.loadAnimation(this,
                        R.anim.right_to_left_out);
                left_to_Right_in = AnimationUtils.loadAnimation(this,
                        R.anim.left_to_right_in);
                Left_to_Right_out = AnimationUtils.loadAnimation(this,
                        R.anim.left_to_right_out);

                frame2.setImageBitmapReset(decryptedimage, 0, true);

                frame2.bringToFront();
                frame2.setVisibility(View.VISIBLE);
                frame1.setVisibility(View.INVISIBLE);
                frame2.setAnimation(Right_to_left_in);
                frame1.setAnimation(Right_to_left_out);                 

            }

Just try to set visibility GONE to other layout elements, so main view will get stretched.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!