微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android:屏幕顶部的不需要的白盒子(工具栏?)

如何摆脱android视图顶部的白框?我在代码中看不到任何地方,我调用了创建工具栏的东西,也没有自己编写代码.它也存在于视图之上,而不是在视图中.我猜在xml文件的设计视图中有一些设置可以切换它吗?提前致谢!

**我还应该包括它仅适用于此活动,而我的其他活动顶部没有此白条.此外,操作栏是白色汽车上方的细蓝色条,因此任何涉及操作操作栏的代码都不会更改白条的状态. **

Android View with weird toolbar

编辑:XML代码如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bucket"
    android:theme="@+id/BucketTheme2"
    android:backgroundTint="#70FFFFFF"
    android:backgroundTintMode="src_over">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TableRow>
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:paddingBottom="5dp"
            android:paddingTop="100dp"
            android:text="Find a place to go around you!"
            android:textColor="#ff000000"
            android:textSize="18dp" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:onClick="randomButtonpressed"
            android:text="RANDOMIZE"
            android:textSize="20dp" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/bucketBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:onClick="bucketButtonpressed"
            android:text="Bucket List"
            android:textSize="20dp" />

    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/searchLocationBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:onClick="searchButtonpressed"
            android:text="Search by Location"
            android:textSize="20dp" />

    </TableRow>

</TableLayout>

</RelativeLayout>

编辑2:BucketTheme2的style.xml代码如下(我最初没有发布,因为它只设置颜色):

<style name="BucketTheme2" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

解决方法:

在Manifest.xml中为应用程序或活动设置主题删除操作栏:

android:theme="@android:style/Theme.Holo.Light.NoActionBar"

或者在onCreate方法的Activity中添加以下代码并导入android.support.v7.app.ActionBar:

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。