的FrameLayout:是有可能把孩子的布局关闭屏幕? [英] FrameLayout: is it possible to put child layout off-screen?

查看:175
本文介绍了的FrameLayout:是有可能把孩子的布局关闭屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有可能有结构类似下面的。
而拥有的LinearLayout是在前面被关闭屏幕:

is it possible to have structure like the one below. And have LinearLayout that is at front to be off screen:

<FrameLayout>

   <LinearLayout>
   .. Back Layout
   </LinearLayout>

   <LinearLayout>
   .. Front layout
   </LinearLayout>

</FrameLayout>

下面是图片。
我曾尝试:
我曾尝试设置机器人:layout_marginLeft = - 300dp为的LinearLayout A(正面),但只要我测试它在我的手机上的布局是背可见区域内。
我也曾尝试推布局了与TranslateAnimation屏幕,动画结束后布局是背可见区域内。

Here is the image. What I have tried: I have tried setting android:layout_marginLeft="-300dp" for LinearLayout A (front), but as soon as I test it on my phone the A layout is back inside of visible area. I have also tried pushing the A layout off the screen with TranslateAnimation, after animation ends A layout is back inside of visible area.

请帮我解决这个问题。谢谢。

Please help me solve the problem. Thank you.

推荐答案

所以,如果有人需要这样的事我这里怎么解决它。
对内容的上方滑动菜单。
如问题描述的布局结构。下面是一个XML格式的简单的动画:
show_menu.xml

So in case anyone needs something like this here how I solved it. Sliding menu on top of content. Layout structure as described in the question. Here is a simple animation in xml: show_menu.xml

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

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="-100%" 
        android:toXDelta="0%"
        android:duration="400">
    </translate>
</set>

hide_menu.xml:

hide_menu.xml:

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="0%" 
        android:toXDelta="-100%"
        android:duration="400">
    </translate>
</set>

在MyActivity

in MyActivity

//loading hide animation and setting listener.
anim = AnimationUtils.loadAnimation(this, R.anim.hide_menu); 
    anim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }
        //on animation end setting visibility to gone
        @Override
        public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            MenuList.setVisibility(View.GONE);
        }
    });

同样的事情动画做了show_menu animtaion除了它会对onAnimationStart设置的可见性可见。
菜单列表中的code是在提问,图中的布局。

Same thing is done for animation for show_menu animtaion except it would have onAnimationStart setting visibilty to visible. MenuList in the code is A layout from the figure in the question.

更新:
*的做今天滑动菜单,最好的办法是使用DrawerLayout。的*

这篇关于的FrameLayout:是有可能把孩子的布局关闭屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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