Change AppBarLayout height programmatically in Android
问题 I'm trying to implement Flexible Space with image pattern, using this tutorial. Everything works fine. Notice the height definition of the AppBarLayout which is 192dp. I'd like to make the height 1/3 of the screen instead, to match this google example for the pattern here. Here's the code in the activity's onCreate (the layout xml is exactly the same as in the tutorial): AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar); float density = getResources().getDisplayMetrics().density;