IT

작업 표시 줄을 영구적으로 비활성화하는 방법

lottoking 2020. 7. 3. 18:04
반응형

작업 표시 줄을 영구적으로 비활성화하는 방법


이 코드를 사용하여 벌집에서 작업 표시 줄을 숨길 수 있습니다.

getActionBar().hide();

그러나 키보드가 열리고 사용자가 아무 것도 복사하여 붙여 넣으면 작업 표시 줄이 다시 표시됩니다. 작업 표시 줄을 영구적으로 비활성화하려면 어떻게합니까?


3.2 이전 장치 Theme.Holo.Light에서 Theme.Holo.Light.NoActionBar변형 을 사용하려는 경우 다음에 추가 할 수 있습니다 styles.xml.

<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style> 

그런 다음 활동 테마로 설정하십시오.

<activity android:theme="@style/NoActionBar" ... />

매니페스트에서 활동 테마를 설정하면

<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
....
>

내 onCreate 함수 내에서 다음 코드를 사용합니다.

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

출처 : https://developer.android.com/guide/topics/ui/actionbar.html


<application
    .
    .
    android:theme="@android:style/Theme.Holo.Light.NoActionBar"
    . >

아마도 이것은 당신을 도울 것입니다


Android Studio에서 기본적으로 생성 된 Activity 수퍼 클래스는 ActionBarActivity다른 응답의 솔루션이 작동하지 않습니다. 슈퍼 클래스 변경을 해결하려면 다음을 수행하십시오.

public class xxxActivity extends ActionBarActivity{

에:

public class xxxActivity extends Activity {

사용자 정의 테마를 제공하고 작업 표시 줄을 제공하지 않는 가장 좋은 방법은 프로젝트의 모든 활동에 대해 SuperClass를 작성하고 onCreate ()에서 다음 코드 행을 호출하는 것입니다.

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

그것은 항상 나를 위해 작동합니다. 이 방법의 유일한 문제는 앱을 시작할 때 몇 분의 작업 표시 줄이 표시된다는 것입니다 (활동이 아니라 완전한 앱).


actionBar 및 Title없이 전체 화면을 표시하려는 경우.

style.xml에 추가하십시오.

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

manifest.xml에서 스타일을 사용하십시오.

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

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    getSupportActionBar().hide();
}

styles.xml로 이동이 DarkActionBar를 NoActionBar로 변경하십시오.

style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

Holo 테마를 사용하지 않으면 작업 표시 줄이 사라집니다. 이 코드는 지원 lib v7과 함께 API 8 이상에서 작동합니다.

<style name="NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>

활동에 대한 테마를 설정하십시오.

<activity android:theme="@style/NoActionBar" ... />

그리고 당신의 활동 수업에서.

ActionBarActivity를 확장하더라도 작동합니다.


If you just want a theme with no action bar you can use 'NoActionBar' variant, for eg. if your base theme is as below

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

then you can use

<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

But if you want to retain the properties of your main theme i.e. AppTheme you can do as below

<style name="AppThemeNoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

You can retain all the properties of your base theme this way and don't have to explicitly add them in your NoActionBar theme :)


Heres a quick solution.

You find styles.xml and you change the base application theme to "Theme.AppCompat.NoActionBar" as shown below.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
</style>

You can force hide the action bar simply:

ActionBar  actionbar = getSupportActionBar();
actionBar.hide();

Just use your default theme.


Under res -> values ->styles.xml

Change

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

To

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


Below are the steps for hiding the action bar permanently:

  1. Open app/res/values/styles.xml.
  2. Look for the style element that is named "apptheme". Should look similar to <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">.
  3. Now replace the parent with any other theme that contains "NoActionBar" in its name.

    a. You can also check how a theme looks by switching to the design tab of activity_main.xml and then trying out each theme provided in the theme drop-down list of the UI.

  4. If your MainActivity extends AppCompatActivity, make sure you use an AppCompat theme.


Type this code to your onCreate method before setContentView:

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

I would like to post rather a Designer approach to this, this will keep design separate from your business logic:

Step 1. Create new style in (res->values->styles.xml) : Basically it is copy of your overall scheme with different parent - parent="Theme.AppCompat.Light.NoActionBar"

<!-- custom application theme. -->
    <style name="MarkitTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:windowNoTitle">true</item>
    </style>

Step 2: In your AndroidManifest.xml, add this theme to the activity you want in: e.g. I want my main activity without action-bar so add this like below:

<activity android:name=".MainActivity"
            android:theme="@style/MarkitTheme">

This is the best solution for me after trying a lot of things.


Make sure you create a new theme by changing the name of the default theme in the styles.xml file to:

 <style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar">

and than change the theme from the drop-down under your main_activity.xml to whatever you called your theme.


Another interesting solution where you want to retain the ViewPager while removing the action bar is to have a style as show

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:actionBarStyle">@style/NoActionBarStyle</item>
    <item name="android:windowContentOverlay">@null</item>
</style>
<style name="NoActionBarStyle" parent="android:Widget.Holo.ActionBar">
    <item name="android:backgroundSplit">@null</item>
    <item name="android:displayOptions"></item>
</style>

This is the way most of the Dialer applications in android is showing the ViewPager without the action bar.

Ref: https://github.com/CyanogenMod/android_packages_apps_Dialer


in the onCreate function add the following code

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

and just import android.support.v7.app.ActionBar


try this in your manifist

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

  protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
    setContentView(R.layout.activity_main);

There are two ways to disable ActionBar in Android.

requestWindowFeature(Window.FEATURE_NO_TITLE); 
setContentView(R.layout.activity_main); 

I use this solution:

in the manifest, inside your activity tag:

android:label="@string/empty_string"

and in strings.xml:

<string name="empty_string">""</string>

This way you keep ActionBar (or Toolbar) with the title, but when Activity if created the title is automatically empty.


Strangely enough, none of these worked for me when building on a Nexus 7 running 4.4.2 (API 19). For the most part, at least with the latest version of Android Studio (1.2.1.1) after creating a blank activity app, the:

android:theme="@style/AppTheme"

is in the application element, not the activity element. If I removed the above code or tried to change it to:

android:theme="@android:style/Theme.Holo.Light.NoActionBar"

the app won't run...if this is happening to you, just go into your styles.xml file (res > values > styles.xml) and add the .NoTitleBar to the end of the parent like this block:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"></style>

No changes to the AndroidManifest file are needed.

참고URL : https://stackoverflow.com/questions/8456835/how-to-disable-action-bar-permanently

반응형