본문 바로가기
Android

actionbar 제거

by 캡틴노랑이 2021. 7. 11.
반응형

제거 방법 1

 

res\values\themes\themes.xml의 내용을 수정.

위 두개의  theme.xml 수정함. 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.DroneHybrid" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
 
        <!--이 것 추가 -->
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <!--이 것 추가 -->
    </style>
</resources>

 

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

 

 

제거 방법 2

소스에서 제거 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_site);
 
       ActionBar actionBar = getSupportActionBar();
       actionBar.hide();
 
       String url = "";
 
       webView = findViewById(R.id.webView);
       webView.getSettings().setJavaScriptEnabled(true);
       webView.setWebViewClient(new WebViewClient());
       webView.setWebChromeClient(new WebChromeClient());
 
       Intent intent = getIntent();
       url = (String) intent.getSerializableExtra("url");
 
       webView.loadUrl(url);
   }

 

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

 

위 코드만 추가하면됨. 단 소스로 할경우  activity별로 다 해줘야됨. 

 

 

특정 activity만 할 것이면, 소스.

전체를 적용할 것이면,  theme.

 

 

반응형