无法删除我的Android项目中的活动标题,其中minSdkVersion = 9,targetSdkVersion = 21

时间:2015-03-28 18:44:51

标签: android android-layout android-intent android-fragments android-activity

我是android新手。 我试图隐藏我活动的标题栏,但我每次都失败了。

我的style.xml是

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

尝试失败1

requestWindowFeature(Window.FEATURE_NO_TITLE);

尝试失败2

final ActionBar actionBar = getActionBar();
 actionBar.setDisplayShowTitleEnabled(false);

尝试失败3

<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">

我的活动是

public class JobDetailsView extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {


        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);


        setContentView(R.layout.activity_job_details_view);
    }
}

有人可以帮忙吗??

3 个答案:

答案 0 :(得分:1)

在清单文件中使用它:

<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar">

答案 1 :(得分:0)

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

oncreate()方法中。

之前:

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);

或者您可以使用

@android:style/Theme.NoTitleBar

答案 2 :(得分:0)

在资源文件中添加这些样式。

  <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">

</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">     
    <item name="android:windowNoTitle">true</item>     
</style>

并将此主题添加到您的应用和活动中,

android:theme="@style/AppTheme"

在清单文件中,希望它能够正常工作。

注意:请注意,您不应该扩展 ActionBarActivity ,而是在活动类中使用活动进行尝试。然后它就会起作用。

快乐的编码。

相关问题