Hoe verwijder ik de titelbalk van de Android-activiteit?

Kan iemand me alsjeblieft helpen met het probleem. Ik wil dat mijn activiteit op volledig scherm wordt weergegeven en ik wil de titel van het scherm verwijderen. Ik heb verschillende manieren geprobeerd, maar ik kan het niet verwijderen.

Activiteitscode:

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);
   }
}

En 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>

Ik wil de titelbalk in blauwe kleur verwijderen. Zoek de afbeelding voor de referentie:

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>

Antwoord 1, autoriteit 100%

Probeer dit:

this.getSupportActionBar().hide();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try
    {
        this.getSupportActionBar().hide();
    }
    catch (NullPointerException e){}
    setContentView(R.layout.activity_main);
}

Antwoord 2, autoriteit 90%

je voegt deze stijl gewoon toe aan je style.xml-bestand dat zich in je waardenmap bevindt

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

Stel daarna deze stijlin op uw activiteitsklasse in uw AndroidManifest.xml-bestand

android:theme="@style/AppTheme.NoActionBar"

Bewerken:-als je de programmatische manier gebruikt om ActionBar te verbergen, gebruik dan onderstaande code in je activiteit onCreate()methode.

if(getSupportedActionbar()!=null)    
     this.getSupportedActionBar().hide();

en als je ActionBar wilt verbergen voor Fragment, dan

getActivity().getSupportedActionBar().hide();

AppCompat v7:-
Gebruik het volgende thema in uw activiteiten waar u actiobBar Theme.AppComat.NoActionBarof Theme.AppCompat.Light.NoActionBarniet wilt of als u het in de hele app wilt verbergen stel dit thema in in uw <application... />in uw AndroidManifest.

In Kotlin:

voeg deze regel code toe aan uw onCreate()-methode of u kunt het bovenstaande thema gebruiken.

supportActionBar?.hide()

ik hoop dat dit je meer zal helpen.


Antwoord 3, autoriteit 15%

Je kunt het proberen:

<activity android:name=".YourActivityName"
          android:theme="@style/Theme.Design.NoActionBar">

dat werkt voor mij


Antwoord 4, autoriteit 13%

In uw Android-manifest-bestand zorg ervoor dat de activiteit dit (of a) thema (dat is gebaseerd op) @style/Theme.AppCompat.NoActionBar
Dit verwijdert de actiebalk volledig, maar maakt uw activiteit niet op volledig scherm.
Als u uw activiteiten volledig wilt maken, gebruikt u dit thema

@android:style/Theme.NoTitleBar.Fullscreen

of u zou kunnen wijzigen

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

Naar

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

Dit is wat ik gebruik om volledig scherm te krijgen bij runtime

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                mDecorView = getWindow().getDecorView();
                mDecorView.setSystemUiVisibility(
                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                                | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                                | View.SYSTEM_UI_FLAG_IMMERSIVE);
            }

Om volledig scherm te verlaten, gebruik ik dit

mDecorView = getWindow().getDecorView();
mDecorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

Antwoord 5, autoriteit 9%

Activiteit toevoegen

requestWindowFeature(Window.FEATURE_NO_TITLE);

en voeg uw style.xml-bestand toe met de volgende twee regels:

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

Antwoord 6, autoriteit 4%

Je voegt gewoon de volgende regels code toe aan het style.xml-bestand

<style name="AppTheme.NoTitleBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

appthema wijzigen in bestand AndroidManifest.xml

android:theme="@style/AppTheme.NoTitleBar"

Antwoord 7

Voeg deze twee regels toe aan je style.xml

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

Other episodes