如何从android活动中删除标题栏? [英] How to remove title bar from the android activity?

查看:89
本文介绍了如何从android活动中删除标题栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我解决这个问题.我希望我的活动显示为全屏,并且希望从屏幕上删除标题.我尝试了几种方法,但无法将其删除.

Can someone please help me with the issue.I want my activity as full screen and want to remove title from the screen.I have tried several ways but not able to remove it.

活动代码:

public class welcomepage extends Activity {
    private Button btn;
    EditText userName,passWord;
    DatabaseHandler dbHandler;
    Context ctx =this;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_welcomepage);
   }
}

和Activity.xml

And Activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout    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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/pic1"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.edkul.vimal.edkul.welcomepage">

</RelativeLayout>

我要删除显示为蓝色的标题栏.请找到图片以供参考:

I want to remove the title bar displayed in blue color .Please find the image for the reference :

AndroidManifest.xml

AndroidManifest.xml

<application
        android:minSdkVersion="3"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <activity
            android:name=".welcomepage"
            android:label="@string/app_name"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>

推荐答案

尝试一下:

this.getSupportActionBar().hide();

this.getSupportActionBar().hide();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try
    {
        this.getSupportActionBar().hide();
    }
    catch (NullPointerException e){}

    setContentView(R.layout.activity_main);
}

这篇关于如何从android活动中删除标题栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆