You can also hide the title of an activity if desired ( Such as when you just want to display a status update to the user). To do so , use the requestWindowFeature() method and pass it the window .FEATURE_NO_TITLE constant, like This :
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate ( Bundle savedInstanceState )
{
super.onCreate (savedInstanceState );
setContentView (R.layout.activity_main);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
Now you need change the theme in the AndoirdManifest.xml to a theme that has no title bar. Be sure to change all instances of "com.android" to whatever.package name your project is using.
package com.android.activity101;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmls:tool="http://schemas.android.com/tools"
package="com.android.activity101">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</inrtent-filter>
<activity>
<application>
</mainfest>
If your can Download the code please Click here.
View a Video please click here.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate ( Bundle savedInstanceState )
{
super.onCreate (savedInstanceState );
setContentView (R.layout.activity_main);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
Now you need change the theme in the AndoirdManifest.xml to a theme that has no title bar. Be sure to change all instances of "com.android" to whatever.package name your project is using.
package com.android.activity101;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmls:tool="http://schemas.android.com/tools"
package="com.android.activity101">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</inrtent-filter>
<activity>
<application>
</mainfest>
If your can Download the code please Click here.
View a Video please click here.
Comments
Post a Comment