Android布局崩溃 [英] Android layout collapse

查看:114
本文介绍了Android布局崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用



当我在我的设备中运行应用程序时,布局很乱,如下图所示。您可以看到IjkVieoView的背景位于XWalkView前面,但IjkVideoView中播放的视频位于XWalkView后面,因为视频的上半部分已被XWalkView覆盖。





布局xml,

 <?xml version =1.0encoding =utf-8?> 
< LinearLayout xmlns:android =http://schemas.android.com/apk/res/android
xmlns:app =http://schemas.android.com/apk/res -auto
xmlns:tools =http://schemas.android.com/tools
android:orientation =verticalandroid:layout_width =match_parent
android:layout_height = match_parent >

< RelativeLayout
android:layout_width =match_parent
android:layout_height =match_parent
tools:ignore =UselessParent>

<! - 这可能是你的片段容器,或者其他东西 - >

< org.xwalk.core.XWalkView xmlns:android =http://schemas.android.com/apk/res/android
android:id =@ + id / xWalkView
android:layout_width =fill_parent
android:layout_height =160dp
android:background =@ color / blue
android:isScrollContainer =true >

< /org.xwalk.core.XWalkView>

< com.xxxxxx.app.widget.media.IjkVideoView
android:id =@ + id / video_view
android:layout_width =200dp
android:layout_height =200dp
android:layout_alignParentTop =true
android:layout_centerHorizo​​ntal =true
android:layout_marginTop =72dp
android:background = @ color / colorAccent/>

< com.roughike.bottombar.BottomBar
android:id =@ + id / bottomBar
android:layout_width =match_parent
android:layout_height =60dp
android:layout_alignParentBottom =true
app:bb_tabXmlResource =@ xml / web_tabs/>

< / RelativeLayout>
< / LinearLayout>

活动java代码,

  protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Log.d(INFO,已输入);
setContentView(R.layout.activity_web);
mXWalkView =(XWalkView)findViewById(R.id.xWalkView);
XWalkSettings webSettings = mXWalkView.getSettings();
webSettings.setJavaScriptEnabled(true);
mXWalkView.addJavascriptInterface(new JsInterface(),NativeInterface);

videoView =(IjkVideoView)findViewById(R.id.video_view);
videoView.setAspectRatio(IRenderView.AR_ASPECT_FILL_PARENT);
videoView.setVideoURI(Uri.parse(http://live.xxxxxx.com/live/40xx27.flv));
videoView.start();

final Bundle extras = getIntent()。getExtras();
mXWalkView.load(http:// xxxxxxxxxxxxxx,null);
}


解决方案

您的布局似乎是正确的。它可能会从lib中被打破。它已经有1k +问题。



也许您可以使用包含视频的自定义对话框并显示该对话框。这样视频就会出现在图像前面。然后你可以尝试删除阴影或 bgColor = transparent ,这样用户可能没有意识到这是一个对话框。这个黑客可能有效。


I use a XWalkView to load webpage and a IjkVideoView to play live video in my app. I want the IjkVideoView playing the video in front the XwalkView, so I put these two view in a relativelayout and IijVideoView behind the XWalkView.

In the android studio's Component Tree of Design window the layout seems ok as below image,

While when I run the app in my device, the layout is in mess as below image. You can see the background of IjkVieoView is in front of XWalkView, but the video playing in the IjkVideoView is behind the XWalkView, as the upper part of the video has been covered by the XWalkView.

layout xml,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="UselessParent">

        <!-- This could be your fragment container, or something -->

        <org.xwalk.core.XWalkView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/xWalkView"
            android:layout_width="fill_parent"
            android:layout_height="160dp"
            android:background="@color/blue"
            android:isScrollContainer="true">

        </org.xwalk.core.XWalkView>

        <com.xxxxxx.app.widget.media.IjkVideoView
            android:id="@+id/video_view"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="72dp"
            android:background="@color/colorAccent" />

        <com.roughike.bottombar.BottomBar
            android:id="@+id/bottomBar"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            app:bb_tabXmlResource="@xml/web_tabs" />

    </RelativeLayout>
</LinearLayout>

activity java code,

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("INFO", "entered");
        setContentView(R.layout.activity_web);
        mXWalkView = (XWalkView) findViewById(R.id.xWalkView);
        XWalkSettings webSettings = mXWalkView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mXWalkView.addJavascriptInterface(new JsInterface(), "NativeInterface");

        videoView = (IjkVideoView) findViewById(R.id.video_view);
        videoView.setAspectRatio(IRenderView.AR_ASPECT_FILL_PARENT);
        videoView.setVideoURI(Uri.parse("http://live.xxxxxx.com/live/40xx27.flv"));
        videoView.start();

        final Bundle extras = getIntent().getExtras();
        mXWalkView.load("http://xxxxxxxxxxxxxx", null);
}

解决方案

Your layout seems to be correct. It might be broken from the libs. It already has 1k+ issues.

Maybe you can use a custom dialog that has the video in it and show that dialog. This way the video will be in front of the images. Then you can try to remove the shadow or bgColor = transparent, so that the user might not realise that is a dialog. This hack may work.

这篇关于Android布局崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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