机器人,动画,如何进出的屏幕布局滑动? [英] Android, animation, How to sliding in and out a layout from screen?

查看:110
本文介绍了机器人,动画,如何进出的屏幕布局滑动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序需要通过相机来记录。在拍摄过程中我展示了一些项目,如在屏幕菜单上。我要当用户点击一个箭头滑出菜单,屏幕,它在当用户触摸屏幕上滑动。

In my application I need to record by camera. During recording I show some items as menu on screen. I need to slide out menu from screen when user clicks an arrow and slide it in when user touched the screen.

我有两个问题。 1),看来我的动画不能正常工作。 2)当我设置RelativeLayout的,以显示/隐藏只是认为生效,摄像头视图不得到整个画面,你在图片看到(我不希望看到黑色背景)。

I have two problem. 1) It seems my animation doesn't work. 2) when i set RelativeLayout to visible/invisible just the view take effect, camera view doesn't get the whole of screen as you see in images (I don't want see black background).

R.anim.slide_in_up:

R.anim.slide_in_up:

<?xml version="1.0" encoding="utf-8"?>

<translate 
    xmlns:android       = "http://schemas.android.com/apk/res/android"
    android:fromYDelta  = "100%p" 
    android:toYDelta    = "0%p"
    android:duration    = "3000" />

R.anim.slide_out_up:

R.anim.slide_out_up:

<?xml version="1.0" encoding="utf-8"?>

<translate 
    xmlns:android       = "http://schemas.android.com/apk/res/android"
    android:fromYDelta  = "0%p" 
    android:toYDelta    = "100%p"
    android:duration    = "3000" />

code,用于显示slide_in_up:

Code, for showing slide_in_up:

rlMenu = (RelativeLayout) findViewById(R.id.rlMenu);
        imHide  = (ImageView) findViewById(R.id.btn_hide);
        imHide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                rlMenu.setVisibility(View.INVISIBLE);
                overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
            }
        });

code,用于显示slide_out_up:

Code, for showing slide_out_up:

@Override
    public boolean onTouchEvent(MotionEvent event) {

        rlMenu.setVisibility(View.VISIBLE);
        overridePendingTransition(R.anim.slide_out_up, R.anim.slide_in_up);

        return super.onTouchEvent(event);
    }

屏幕布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android           = "http://schemas.android.com/apk/res/android"
    android:layout_width    = "fill_parent"
    android:layout_height   = "fill_parent"
    android:orientation     = "vertical" >



     <FrameLayout
        android:id              = "@+id/camera_preview"
        android:layout_width    = "fill_parent"
        android:layout_height   = "0dip"
        android:layout_weight   = "1" />



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

         <RelativeLayout
             android:layout_width           = "240dip"
             android:layout_height          = "50dip"
             android:background             = "@drawable/btn_top_edge_right"
             android:layout_alignParentLeft = "true" >

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

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

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


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

     </RelativeLayout>
</LinearLayout>

如何删除整个RelativeLayout的和放大摄像机视图与我的动画? 谢谢

How can I remove the whole of RelativeLayout and enlarge camera view with my animation? Thanks

推荐答案

答到的第二个问题。试着改变如下布局:

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.

这篇关于机器人,动画,如何进出的屏幕布局滑动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆