I am creating an android app but I have some problem I cant remove this blue heading or I don’t know how its called, or action bar ? I have tried some methods but they didn’t work.
我正在创建一个Android应用程序,但我有一些问题,我不能删除这个蓝色标题或我不知道它是如何调用,或动作栏?我尝试了一些方法,但它们没有用。
<?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"
tools:showIn="@layout/activity_main"
tools:context=".MainActivity"
android:background="#9AEA30">
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:id="@+id/imageView"
android:src="@drawable/discount"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
7 个解决方案
#1
1
The easiest way to remove it is to make your Activity
extend the Activity
class and not the AppCompatActivity
.
删除它的最简单方法是使Activity扩展Activity类而不是AppCompatActivity。
That is do something like this:
这是做这样的事情:
public class MyActivity extends Activity {
}
#2
3
What did you try?
你尝试了什么?
Just add this in styles.xml
只需在styles.xml中添加它即可
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
And
和
android:theme="@style/AppTheme"
in AndroidManifest.xml
in application
section.
在应用程序部分的AndroidManifest.xml中。
#3
1
In your style file (res/values/styles.xml) is declared the style of your project.
在您的样式文件(res / values / styles.xml)中声明了项目的样式。
For example
例如
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Change "Theme.AppCompat.Light.DarkActionBar" with "Theme.AppCompat.Light.NoActionBar"
使用“Theme.AppCompat.Light.NoActionBar”更改“Theme.AppCompat.Light.DarkActionBar”
like this
喜欢这个
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
The same can be achieved for Dark themes.
黑暗主题也可以实现同样的效果。
#4
0
If you're on Android Studio, you'll have a choice to change the Theme from the preview windows without any code.
如果您使用的是Android Studio,则可以选择从预览窗口更改主题而无需任何代码。
#5
0
This method work for me :
这个方法对我有用:
Remove this code from following activity_main.xml :
从以下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" />
#6
0
may be late but i found a way too just remove the following code from your xml layout
可能会迟到但我发现一种方法也只是从你的xml布局中删除以下代码
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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>
#7
0
This is the simplest and cleanest solution IMO:
这是IMO最简单,最干净的解决方案:
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
#1
1
The easiest way to remove it is to make your Activity
extend the Activity
class and not the AppCompatActivity
.
删除它的最简单方法是使Activity扩展Activity类而不是AppCompatActivity。
That is do something like this:
这是做这样的事情:
public class MyActivity extends Activity {
}
#2
3
What did you try?
你尝试了什么?
Just add this in styles.xml
只需在styles.xml中添加它即可
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
And
和
android:theme="@style/AppTheme"
in AndroidManifest.xml
in application
section.
在应用程序部分的AndroidManifest.xml中。
#3
1
In your style file (res/values/styles.xml) is declared the style of your project.
在您的样式文件(res / values / styles.xml)中声明了项目的样式。
For example
例如
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Change "Theme.AppCompat.Light.DarkActionBar" with "Theme.AppCompat.Light.NoActionBar"
使用“Theme.AppCompat.Light.NoActionBar”更改“Theme.AppCompat.Light.DarkActionBar”
like this
喜欢这个
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
The same can be achieved for Dark themes.
黑暗主题也可以实现同样的效果。
#4
0
If you're on Android Studio, you'll have a choice to change the Theme from the preview windows without any code.
如果您使用的是Android Studio,则可以选择从预览窗口更改主题而无需任何代码。
#5
0
This method work for me :
这个方法对我有用:
Remove this code from following activity_main.xml :
从以下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" />
#6
0
may be late but i found a way too just remove the following code from your xml layout
可能会迟到但我发现一种方法也只是从你的xml布局中删除以下代码
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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>
#7
0
This is the simplest and cleanest solution IMO:
这是IMO最简单,最干净的解决方案:
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}