Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在布局底部放置横幅时出现问题_Java_Android_Mobile - Fatal编程技术网

Java 在布局底部放置横幅时出现问题

Java 在布局底部放置横幅时出现问题,java,android,mobile,Java,Android,Mobile,对于我的应用程序,我使用清单文件中的主题功能隐藏活动的标题栏和通知栏。在活动的底部,我希望有一个48度高的广告横幅,在这上面,其余的空间应该填满我的类GameView中的一个对象,这只是扩展了SurfaceView,就像月球着陆器样本中看到的那样 我的当前布局为我完成以下任务: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

对于我的应用程序,我使用清单文件中的主题功能隐藏活动的标题栏和通知栏。在活动的底部,我希望有一个48度高的广告横幅,在这上面,其余的空间应该填满我的类GameView中的一个对象,这只是扩展了SurfaceView,就像月球着陆器样本中看到的那样

我的当前布局为我完成以下任务:

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

    <GameView android:id="@+id/game_view"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_weight="1">

<com.admob.android.ads.AdView android:id="@+id/ad"
    android:layout_width="fill_parent" android:layout_height="48dip" />

</LinearLayout>

但是,当我使用home键(在这种情况下,通知栏将返回)离开应用程序,然后切换回我的活动时,会出现问题。当我切换回屏幕时,屏幕会短暂变黑,我绘制的曲面视图显示在通知栏下方,然后通知栏会向上动画并消失,然后曲面视图会移到屏幕顶部。问题是,一个黑色的水平矩形现在遮住了我的广告横幅的顶部,这个横条看起来和通知栏一样高。Ascii艺术:

-------------
|           |
|           |   <- surface view the same size as expected
|           |
|           |
#############   <- black rectangle
|           |   <- ad banner with the top part masked by the rectangle
-------------
-------------
|           |

||如果您在清单中使用
android:theme=“@android:style/theme.NoTitleBar.Fullscreen”
,而不是通过Java代码删除通知栏,则此问题可能会消失。至少,我看不到您在使用此主题进行测试时所描述的动画效果。

请发布您的
活动
中的一些代码,其中显示了哪些方法正在设置
无标题
功能和
全屏
标志,以及它们的顺序。谢谢,我已经添加了将应用程序设置为全屏的清单代码。我不使用方法调用。谢谢,但我已经用这种方式切换到全屏。没有方法调用执行此操作。我认为这个问题与在我的曲面视图下有一个固定大小的横幅有关(您的项目似乎在布局中只使用一个大的曲面视图)。你能想到我可以试试的东西吗?我现在别无选择。我注意到,如果我用图像视图等替换曲面视图,我不会遇到同样的问题。我想这可能与曲面视图决定它想要的大小有关。@rebeccamaher:毫无疑问,
SurfaceView
是一只奇怪的鸟。您在什么设备上看到这种行为?您也可以尝试切换到
RelativeLayout
,因此横幅的位置是由明确的布局规则决定的,而不是由
SurfaceView
的最终大小决定的。@rebeccamaher:我在一个里程碑上测试这一点,但它也发生在模拟器中。我尝试了一种相对布局的方法。我想我可以尝试不同的排列,哪种观点与什么观点相对。
<application android:label="@string/app_name" android:icon="@drawable/app_icon">
    <activity android:name="MainActivity" android:label="@string/app_name"
        android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
....