Jai*_*dra 39 android android-actionbar
我想在操作栏中启用主页按钮.我正在使用此代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
}
Run Code Online (Sandbox Code Playgroud)
在这里,我正在使用setHomeButtonEnabled
并setDisplayHomeAsUpEnabled
在ActionBar中的图标上添加一个背面标记.如果我只使用setDisplayHomeAsUpEnabled
那么它也会起作用吗?是否需要设置setHomeButtonEnabled
为true?
两者有什么区别?
yDe*_*uis 77
对于你想做的事,actionBar.setDisplayHomeAsUpEnabled(true)
就足够了.
区别在于:actionBar.setHomeButtonEnabled(true)
只会使图标可点击,图标背景的颜色作为点击的反馈.
actionBar.setDisplayHomeAsUpEnabled(true)
将使图标可点击并添加<
图标左侧的图标.
正如安卓所说:
- setDisplayShowHomeEnabled(boolean showHome)
// Set whether to include the application home affordance in the action bar.
// (and put a back mark at icon in ActionBar for "up" navigation)
-setHomeButtonEnabled(boolean enabled)
// Enable or disable the "home" button in the corner of the action bar.
// (clickable or not)
Run Code Online (Sandbox Code Playgroud)
我想应该很清楚
归档时间: |
|
查看次数: |
29620 次 |
最近记录: |