Issue
i made my first app today using an application named "A.I.D.E". i am an android user and its my first time making an app, how can i remove my app name and lable from the top of the main screen? i named my app "YT Studio" but i dont want to show this name and lable on top of my main screen, i want it to be blank, can someone help me? i gave you my android manifest.xml
and main.java
file for the reference, i would love to edit my question for more help in future.
android manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ojhastudios.ytstudio" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="YT Studio"
android:theme="@style/AppTheme"
android:resizeableActivity = "true">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
main.xml
<LinearLayout
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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
</LinearLayout>
edit: one fellow asked me for code, there you go
package com.mycompany.myapp;
import android.app.*;
import android.os.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getSupportActionBar().hide();
}
}
Solution
You can just call
getSupportActionBar().hide();
in your activity's onCreate()
method.
Edit
The method given above does not work when using AndroidX activity. It works with AppCompatActivity
.
So, this answer will do the task.
In your AndroidManifest.xml
, find your activity and then you should add this line in it:
<application>
...
<activity
android:name=".MainActivity"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
...
</activity>
...
</application>
Answered By - Sambhav Khandelwal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.