【问题标题】:layout works different on different mobile android布局在不同的移动 android 上的工作方式不同
【发布时间】:2017-04-20 11:16:57
【问题描述】:

我正在制作一个视频通话应用程序,我已经为两个人做了设计。一个打电话(发件人)和另一个接听电话(接听人)的人,但我面临的问题是在一部手机上我会得到自己的流和对手流,但在其他具有不同安卓版本的手机上,我会得到对手流,但我自己的流没有显示它会在后台。

samsung s4 image这张图片显示了两个流。

LG G3 没有显示自己的流。它将在后台

但是我为发送者和接收者做了相同的布局。我认为这个问题是由于每个手机上的不同 android 版本造成的。请帮助我如何解决这个问题。

发件人:

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

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/whencalling"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_alignParentBottom="true"
        android:background="#DB2727"
        android:orientation="horizontal"
       >


        <CheckBox
            android:id="@+id/muteVoume"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginTop="10dp"
            android:button="@drawable/mutedrawable" />

        <CheckBox
            android:id="@+id/switchCameraAction2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="175dp"
            android:layout_marginTop="20dp"
            android:button="@drawable/cemeradrawable" />

        <CheckBox
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="10dp"
            android:button="@drawable/micdrawable" />

    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <include
            android:id="@+id/tool_bar"
            layout="@layout/tool_bar"></include>





        <RelativeLayout
            android:id="@+id/whencallhappens"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
          >

                    <LinearLayout
                        android:orientation="horizontal"
                        android:layout_width="fill_parent"
                        android:layout_height="match_parent"
                        >


                        <Space
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_weight="1"/>
                        <LinearLayout
                            android:orientation="horizontal"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:id="@+id/llPrimary">


                            <io.skyway.Peer.Browser.Canvas
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:id="@+id/svPrimary"/>

                        </LinearLayout>

                        <Space
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_weight="1"/>

                    </LinearLayout>


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

                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1.0"/>

                <LinearLayout

                    android:orientation="horizontal"
                    android:layout_width="160dp"
                    android:layout_height="160dp"
                    android:id="@+id/llSecondary"
                    >

                    <io.skyway.Peer.Browser.Canvas
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:id="@+id/svSecondary"/>

                </LinearLayout>

                <Space
                    android:layout_width="20px"
                    android:layout_height="10px"
                    />

            </LinearLayout>





            <Button

                android:id="@+id/callend"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                android:layout_gravity="center|bottom"
                android:layout_marginBottom="80dp"
                android:background="@drawable/endcall" />

        </RelativeLayout>


    </LinearLayout>
</RelativeLayout>

接收者:

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

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

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/whencalling"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_alignParentBottom="true"
        android:background="#DB2727"
        android:orientation="horizontal">


        <CheckBox
            android:id="@+id/muteVoume"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginTop="10dp"
            android:button="@drawable/mutedrawable" />

        <CheckBox
            android:id="@+id/switchCameraAction2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="175dp"
            android:layout_marginTop="20dp"
            android:button="@drawable/cemeradrawable" />

        <CheckBox
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="10dp"
            android:button="@drawable/micdrawable" />

    </RelativeLayout>




    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical">

        <include
            android:id="@+id/tool_bar2"
            layout="@layout/tool_bar2"></include>

        <RelativeLayout
            android:id="@+id/whencallhappens"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
           >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />

                <LinearLayout
                    android:id="@+id/llPrimary"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">


                    <io.skyway.Peer.Browser.Canvas
                        android:id="@+id/svPrimary"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                </LinearLayout>

                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />

            </LinearLayout>


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

                <Space                        
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                    android:layout_weight="1.0" />

                <LinearLayout
                    android:id="@+id/llSecondary"
                    android:layout_width="160dp"
                    android:layout_height="160dp"
                    android:orientation="horizontal">

                    <io.skyway.Peer.Browser.Canvas
                 android:id="@+id/svSecondary"
                 android:layout_width="match_parent"                       
                 android:layout_height="match_parent"                    
                  />

                </LinearLayout>

                <Space
                    android:layout_width="20px"
                    android:layout_height="10px" />

            </LinearLayout>




            <LinearLayout
                android:layout_marginBottom="80dp"
                android:id="@+id/Not_received"
                android:layout_width="wrap_content"
                android:layout_height="60dp"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                >

                <Space
                    android:layout_width="220dp"
                 android:layout_height="match_parent"
                    android:layout_weight="1.0" />


                <Button
                    android:id="@+id/ReceiveCall"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginBottom="80dp"
                    android:layout_marginRight="20dp"
                    android:background="@drawable/callpick" />


                <Button
                    android:id="@+id/EndCall"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginBottom="80dp"                    
                    android:background="@drawable/endcall"                       
                    />


                <Space
                    android:layout_width="300px"
                    android:layout_height="match_parent" />


            </LinearLayout>


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="60dp"
                android:layout_marginBottom="80dp"
                android:layout_alignParentBottom="true">

                <Space
                    android:layout_width="250dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1.0" />

                <Button
                    android:id="@+id/EndVideoCall"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginBottom="80dp"
                    android:background="@drawable/endcall" />

                <Space

                    android:layout_width="350px"
                    android:layout_height="match_parent" />

            </LinearLayout>


        </RelativeLayout>


    </LinearLayout>
</RelativeLayout>

【问题讨论】:

  • 我不认为这是由于不同的 android 版本。您可以在拨打和接听电话的地方发送代码 sn-p。
  • @Mansuu.... 发送方和接收方的 xmls 是相同的,它在 s4 上运行良好,但是当我在不同的移动设备上使用它时,它会隐藏我们自己的流的小块流
  • 您有一些视图的固定高度和宽度。这可能会导致小屏幕设备出现问题。我认为您必须再次检查。

标签: android xml user-interface


【解决方案1】:

使用它来支持所有分辨率设备: https://github.com/intuit/sdp

sdp 用于边距/填充,ssp 用于字体大小。

【讨论】:

  • 我认为它不支持多设备,而是特定布局如何在某些设备上不显示
【解决方案2】:

使用可缩放尺寸单位:

-使用 Android Studio 和 Gradle 将 sdp 添加到您的项目中:

   dependencies {
        compile 'com.intuit.sdp:sdp-android:1.0.4'
   }

-例如在xml中使用:

 <ImageView
    android:id="@+id/spin_view"
    android:layout_width="@dimen/_20sdp"
    android:layout_height="@dimen/_60sdp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="@dimen/_120sdp"/>

【讨论】:

  • android:layout_width="@dimen/_20sdp" 把它放到你的代码中。
  • 每个或只是在父级
  • 使用像这样的维度(例如:@dimen/_20sdp)
猜你喜欢
  • 2017-09-08
  • 1970-01-01
  • 1970-01-01
  • 2018-05-03
  • 2012-06-04
  • 1970-01-01
  • 1970-01-01
  • 2018-12-11
  • 2014-09-20
相关资源
最近更新 更多