3

So I just built an app but across the top is a white bar. I believe its the ActionBar but every attempt to change the color does not work. Any idea on how to remove it or change its color? Thanks.enter image description here

Activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/activity_main_webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <ProgressBar
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerInParent="true"
        android:id="@+id/progressBar1"
        style="@android:style/Widget.ProgressBar.Small.Inverse" />

    <TextView
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerInParent="true"
        android:id="@+id/LoadingText"
        android:layout_below="@+id/progressBar1"
        android:text="@string/loading_txt"
        android:textSize="20sp"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:clickable="true"
        android:src="@android:drawable/ic_menu_edit"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        app:fabSize="normal"
        app:layout_anchorGravity="bottom|right|end"
        app:backgroundTint="#243313"
        app:rippleColor="#FFF" />

</RelativeLayout>

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />


</resources>

styles.xml(v21)

<resources>>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>
</resources>

LogCat:

03-18 20:16:20.495 17416-17416/org.communionchapelefca.ccsatx E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: org.communionchapelefca.ccsatx, PID: 17416
                                                                                java.lang.RuntimeException: Unable to start activity ComponentInfo{org.communionchapelefca.ccsatx/org.communionchapel.ccsatx.MainActivity}: android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class android.support.design.widget.FloatingActionButton
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                    at android.os.Looper.loop(Looper.java:148)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                 Caused by: android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class android.support.design.widget.FloatingActionButton
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                                    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
                                                                                    at android.app.Activity.setContentView(Activity.java:2172)
                                                                                    at org.communionchapel.ccsatx.MainActivity.onCreate(MainActivity.java:48)
                                                                                    at android.app.Activity.performCreate(Activity.java:6251)
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                    at android.os.Looper.loop(Looper.java:148) 
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                 Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class android.support.design.widget.FloatingActionButton
                                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                                    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                                                                    at android.app.Activity.setContentView(Activity.java:2172) 
                                                                                    at org.communionchapel.ccsatx.MainActivity.onCreate(MainActivity.java:48) 
                                                                                    at android.app.Activity.performCreate(Activity.java:6251) 
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                    at android.os.Looper.loop(Looper.java:148) 
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                 Caused by: java.lang.reflect.InvocationTargetException
                                                                                    at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                                                    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                                                                    at android.app.Activity.setContentView(Activity.java:2172) 
                                                                                    at org.communionchapel.ccsatx.MainActivity.onCreate(MainActivity.java:48) 
                                                                                    at android.app.Activity.performCreate(Activity.java:6251) 
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                    at android.os.Looper.loop(Looper.java:148) 
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                 Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
                                                                                    at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)
                                                                                    at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:110)
                                                                                    at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:104)
                                                                                    at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
                                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                                                    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                                                                    at android.app.Activity.setContentView(Activity.java:2172) 
                                                                                    at org.communionchapel.ccsatx.MainActivity.onCreate(MainActivity.java:48) 
                                                                                    at android.app.Activity.performCreate(Activity.java:6251) 
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                    at android.os.Looper.loop(Looper.java:148) 
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
7
  • is on an activity or fragment? @Greg Williams
    – CodeDaily
    Mar 18, 2016 at 23:18
  • never mind i just saw its an activity. go on your manifest and define app theme under main activity. should be something like this. android:theme="@style/NoActionBar"
    – CodeDaily
    Mar 18, 2016 at 23:20
  • that did not work, it still shows the white bar across the top Mar 18, 2016 at 23:45
  • i see did you try the answer i posted and it did not work?
    – CodeDaily
    Mar 18, 2016 at 23:53
  • @Salvatory Baya added the LogCat output I assumed its an ActionBar; how can I confirm if its an ActionBar or StatusBar? Mar 19, 2016 at 0:21

1 Answer 1

10

The problem is in your styles v-21 file

<resources>
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

Change this line

<item name="android:statusBarColor">@android:color/transparent</item>

change '@android:color/transparent' to some other color

3
  • didnt work, it crashed the app. i tried both '@android:color/primary_text_dark` and @android:color/background_dark Mar 19, 2016 at 1:39
  • you can mark my answer as 'accepted' by click on the 'tick' beside the answer :) glad i could help you. Another thing- whatever color you use for the status bar may not be used in older versions of android so do test your app on api<21
    – Shreyans
    Mar 19, 2016 at 17:31
  • I configured the colour to: @color/colorPrimaryDark which gave the same look as my main activity which has the nav_draw model.
    – Dobbo
    Dec 13, 2019 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.