java - Android Studio - Why does the ActionBar always show, even when fully disabled? -
i started android application development , have come across issue actionbar. aware question has been asked few times, , have made changes necessary can see other articles.
currently, main activity looks this: image
as can see, there blue bar @ top of screen directly under notification bar actionbar supposed be. of app themes (i believe) set noactionbar. rid of blue bar can use entire screen put contents.
my code follows:
main_activity.java
package ryanpx2016.golftracker; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.view; import android.view.menu; import android.view.menuitem; import android.widget.button; import android.content.intent; public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button regularscorepageactivitybutton = (button)findviewbyid(r.id.scoresheetbutton); regularscorepageactivitybutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { startactivity(new intent(mainactivity.this, regularscorepageactivity.class)); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout 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:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context=".mainactivity"> <android.support.design.widget.appbarlayout android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.appbarlayout> <include layout="@layout/content_main" /> </android.support.design.widget.coordinatorlayout>
content_main.xml
<?xml version="1.0" encoding="utf-8"?> <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" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showin="@layout/activity_main" tools:context=".mainactivity"> <button style="?android:attr/buttonstylesmall" android:background="@drawable/scoresheet_button" android:layout_width="185dp" android:layout_height="wrap_content" android:text="@string/scoresheet_button" android:id="@+id/scoresheetbutton" android:layout_centervertical="true" android:layout_centerhorizontal="true" /> <button android:background="@drawable/course_buttons" android:layout_width="185dp" android:layout_height="wrap_content" android:text="@string/my_golf_courses_button" android:id="@+id/mygolfcoursesbutton" android:layout_below="@+id/scoresheetbutton" android:layout_alignstart="@+id/scoresheetbutton" android:layout_margintop="35dp" /> <button android:background="@drawable/course_buttons" android:layout_width="185dp" android:layout_height="wrap_content" android:text="@string/my_minigolf_courses_button" android:id="@+id/myminigolfcoursesbutton" android:layout_margintop="35dp" android:layout_below="@+id/mygolfcoursesbutton" android:layout_centerhorizontal="true" /> </relativelayout>
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ryanpx2016.golftracker" > <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" android:theme="@style/apptheme.noactionbar" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".regularscorepageactivity" android:label="@string/title_activity_regular_score_page" android:theme="@style/apptheme.noactionbar" > <intent-filter> <action android:name="ryanpx2016.golftracker.regularscorepageactivity" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> </application> </manifest>
styles.xml
<resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.noactionbar"> <!-- customize 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>
i believe may have toolbar, again, don't know i'm saying :d
any , appreciated. thanks!!
delete activity_main.xml :
<android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:popuptheme="@style/apptheme.popupoverlay" />
Comments
Post a Comment