NullPointerException when getting AppBarLayout and call setFitsSystemWindows()2019 Community Moderator ElectionGet screen dimensions in pixelsStatic way to get 'Context' in Android?Is there a way to get the source code from an APK file?How to get the build/version number of your Android application?Get current time and date on AndroidonActivityResult is not being called in FragmentAndroid - tiled backgrounds occasionally get stretchedAndroid - Google Maps API v2 - NoClassDefFoundErrorAndroid Studio Layout ErrorsOnClickListener not working with fragments
How could a female member of a species produce eggs unto death?
redhat 7 + How to stop systemctl service permanent
Best mythical creature to use as livestock?
Is it illegal in Germany to take sick leave if you caused your own illness with food?
Co-worker team leader wants to inject the crap software product of his friends into our development. What should I say to our common boss?
Welcoming 2019 Pi day: How to draw the letter π?
If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?
Is all copper pipe pretty much the same?
What is the difference between "shut" and "close"?
Want to switch to tankless, but can I use my existing wiring?
Rejected in 4th interview round citing insufficient years of experience
Running a subshell from the middle of the current command
My adviser wants to be the first author
What has been your most complicated TikZ drawing?
US to Europe trip with Montreal layover - is 52 minutes enough?
Making a sword in the stone, in a medieval world without magic
Why must traveling waves have the same amplitude to form a standing wave?
Time dilation for a moving electronic clock
Does Linux have system calls to access all the features of the file systems it supports?
validation vs test vs training accuracy, which one to compare for claiming overfit?
Excess Zinc in garden soil
Do Bugbears' arms literally get longer when it's their turn?
Potentiometer like component
Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?
NullPointerException when getting AppBarLayout and call setFitsSystemWindows()
2019 Community Moderator ElectionGet screen dimensions in pixelsStatic way to get 'Context' in Android?Is there a way to get the source code from an APK file?How to get the build/version number of your Android application?Get current time and date on AndroidonActivityResult is not being called in FragmentAndroid - tiled backgrounds occasionally get stretchedAndroid - Google Maps API v2 - NoClassDefFoundErrorAndroid Studio Layout ErrorsOnClickListener not working with fragments
I am trying to make StatusBar transparent. Here's setTransparentStatusbar()
:
public void setTransparentStatusbar()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);
I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate()
I use super.setContentViewAndSetUpToolBar()
instead of setContentView()
, Here's parts of setContentViewAndSetUpToolBar(int layoutResID)
:
setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);
setTransparentToolbar();
Here's main_toolbar.xml file:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Here's activity's xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
<!--Main layout-->
...
<!--Main layout END-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
layout="@layout/circle_one_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
When I call setTransparentStatusbar()
, program throws NullPointerException, here's error info:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)
android
add a comment |
I am trying to make StatusBar transparent. Here's setTransparentStatusbar()
:
public void setTransparentStatusbar()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);
I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate()
I use super.setContentViewAndSetUpToolBar()
instead of setContentView()
, Here's parts of setContentViewAndSetUpToolBar(int layoutResID)
:
setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);
setTransparentToolbar();
Here's main_toolbar.xml file:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Here's activity's xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
<!--Main layout-->
...
<!--Main layout END-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
layout="@layout/circle_one_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
When I call setTransparentStatusbar()
, program throws NullPointerException, here's error info:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)
android
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12
add a comment |
I am trying to make StatusBar transparent. Here's setTransparentStatusbar()
:
public void setTransparentStatusbar()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);
I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate()
I use super.setContentViewAndSetUpToolBar()
instead of setContentView()
, Here's parts of setContentViewAndSetUpToolBar(int layoutResID)
:
setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);
setTransparentToolbar();
Here's main_toolbar.xml file:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Here's activity's xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
<!--Main layout-->
...
<!--Main layout END-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
layout="@layout/circle_one_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
When I call setTransparentStatusbar()
, program throws NullPointerException, here's error info:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)
android
I am trying to make StatusBar transparent. Here's setTransparentStatusbar()
:
public void setTransparentStatusbar()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);
I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate()
I use super.setContentViewAndSetUpToolBar()
instead of setContentView()
, Here's parts of setContentViewAndSetUpToolBar(int layoutResID)
:
setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);
setTransparentToolbar();
Here's main_toolbar.xml file:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Here's activity's xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
<!--Main layout-->
...
<!--Main layout END-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
layout="@layout/circle_one_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
When I call setTransparentStatusbar()
, program throws NullPointerException, here's error info:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)
android
android
edited Mar 8 at 1:49
Elm Liu
asked Mar 7 at 10:58
Elm LiuElm Liu
217
217
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12
add a comment |
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12
add a comment |
1 Answer
1
active
oldest
votes
Problem solved.
In main_toolbar.xml, id main_appbar
was given. However,
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
the new id circle_one_appbar
will overwrite the old id. Thus, I shouldn't use id main_appbar
to find the AppBarLayout.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042179%2fnullpointerexception-when-getting-appbarlayout-and-call-setfitssystemwindows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Problem solved.
In main_toolbar.xml, id main_appbar
was given. However,
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
the new id circle_one_appbar
will overwrite the old id. Thus, I shouldn't use id main_appbar
to find the AppBarLayout.
add a comment |
Problem solved.
In main_toolbar.xml, id main_appbar
was given. However,
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
the new id circle_one_appbar
will overwrite the old id. Thus, I shouldn't use id main_appbar
to find the AppBarLayout.
add a comment |
Problem solved.
In main_toolbar.xml, id main_appbar
was given. However,
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
the new id circle_one_appbar
will overwrite the old id. Thus, I shouldn't use id main_appbar
to find the AppBarLayout.
Problem solved.
In main_toolbar.xml, id main_appbar
was given. However,
<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>
the new id circle_one_appbar
will overwrite the old id. Thus, I shouldn't use id main_appbar
to find the AppBarLayout.
answered Mar 8 at 13:19
Elm LiuElm Liu
217
217
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042179%2fnullpointerexception-when-getting-appbarlayout-and-call-setfitssystemwindows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show the whole activity code?
– Themelis
Mar 7 at 11:10
whenever you use Appbar layout make sure that wrap up in Coordinate layout.
– Tanveer Munir
Mar 7 at 11:12