Android 使用setCustomView的自定义操作栏-是否充气?
出于某种原因,下面的两个代码块都可以工作,但它们显示的结果略有不同。有人能解释一下区别吗 第1版:Android 使用setCustomView的自定义操作栏-是否充气?,android,android-actionbar,Android,Android Actionbar,出于某种原因,下面的两个代码块都可以工作,但它们显示的结果略有不同。有人能解释一下区别吗 第1版: View customView = getLayoutInflater().inflate(R.layout.custom_test, null); actionBar.setCustomView ( customView ); actionBar.setDisplayOptions ( ActionBar.DISPLAY_SHOW_CUSTOM ); 第2版: actionBa
View customView = getLayoutInflater().inflate(R.layout.custom_test, null);
actionBar.setCustomView ( customView );
actionBar.setDisplayOptions ( ActionBar.DISPLAY_SHOW_CUSTOM );
第2版:
actionBar.setCustomView ( R.layout.custom_test );
actionBar.setDisplayOptions ( ActionBar.DISPLAY_SHOW_CUSTOM );
在第一个选项中,将父根上的视图设置为null,这意味着在将其设置为actionBar视图后,它不会继承其根属性(android本机上设置的填充/边距和其他样式参数),在第二个版本中,您没有指定null父级,因此它继承自本机actionBar根样式