Android的景观从右到左的景观活动 [英] Android landscape right to landscape left event

查看:193
本文介绍了Android的景观从右到左的景观活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想现在如果是触发时的布局是因为直接从横向正确的方向切换到横向向左方向的情况下被重绘事件任何可能的方式。

我试过OrientationEventListener。问题是,它触发快。我在做用户界面的变化,他们碰巧景观被重绘之前,它看起来不错。

我只需要添加一些延迟的变化,但根据手机上的这种变化可能会持续多跌少。

对于onConfigurationChanged的时机是完美的,但当然它仅适用于纵向到横向或横向到纵向。

我的应用程序不能停留在这个变化,所以使用的onPause,的onStop等是不是一种选择。

所以我在寻找类似onConfigurationChanged一个事件,还包括景观从右到左的景观变化。

解决方案
  

我试过OrientationEventListener。的问题是,它触发   就快了。我在做用户界面的变化,他们碰巧在景观前   被重绘,这很糟糕。

您可以使用handler.post(可运行),这样,你的用户界面的变化重绘之前shouldn`t发生,但是会被排队在主线程并执行它完成图纸后。

  handler.post(新的Runnable(){

        @覆盖
        公共无效的run(){
        //你想要的用户界面的变化

        }
    });
 

如果这仍然不`吨帮帮忙,你可以尝试一个艰难和丑陋的方式来利用定向听众和onLayout()方法:)

I would like to now if the is any possible way to trigger an event when the layout is being redrawn because of the event of switching directly from landscape right orientation to landscape left orientation.

I tried the OrientationEventListener. The problem is that it triggers to fast. I am doing UI changes and they happen before the landscape is being redrawn, and it looks bad.

I could just add some delay on the changes but depending on the phone that change could last more or less.

For the onConfigurationChanged the timing is perfect, but of course it only works for portrait to landscape or landscape to portrait.

My application must not pause in this change, so using onPause, onStop, etc is not an option.

So I am looking for an event similar to onConfigurationChanged that also covers landscape right to landscape left changes.

解决方案

I tried the OrientationEventListener. The problem is that it triggers to fast. I am doing UI changes and they happen before the landscape is being redrawn, and it looks bad.

You can use handler.post(runnable), that way your UI changes shouldn`t happen before the redrawn, but will be queued on the main thread and executed after it finishes drawing.

handler.post(new Runnable() {

        @Override
        public void run() {
        //do the UI changes you want

        }
    });

If this still doesn`t help out you can try a difficult and ugly way to make use of orientation listener and the onLayout() method :)

这篇关于Android的景观从右到左的景观活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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