动作条home键是Nexus 5的错位 [英] ActionBar home button is misplaced in Nexus 5
问题描述
我使用的ActionBar福尔摩斯与自定义主页按钮。在Nexus 5的home键被放错位置的动作条的右侧。您可以从图像中看到它。有没有人想出了这个问题吗?
感谢您。
其他设备(如的Nexus 4,三星Galaxy S4等)
5的Nexus
有关显示自定义主页按钮,我现在用
actionBar.setDisplayShowCustomEnabled(真);
我用 RelativeLayout的
我的自定义视图,我认为这是造成我有问题。我与的LinearLayout
切换,并设置一些属性,我的问题解决了。这些性质
actionBar.setDisplayShowCustomEnabled(真);
actionBar.setDisplayShowTitleEnabled(假);
actionBar.setHomeButtonEnabled(假);
actionBar.setDisplayHomeAsUpEnabled(假);
不过,我不明白为什么它与其他设备,如三星Galaxy S4,的Nexus 4等,不与Nexus 5和Nexus 7运行良好。
效果很好在我切换到的LinearLayout
我尝试了各种办法来解决我的问题,包括设备和设置编程利润率控制。
对于那些仍然坚持使用 RelativeLayout的
为ActionBarSherlock customView你可以使用我不建议的解决方法。
如果(Build.MODEL.contains(Nexus 5的)){
的LayoutParams PARAMS =新的LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.setMargins(-150,0,0,0);
actionBar.setCustomView(V,则params);
}
I'm using ActionBar Sherlock with custom home button. In Nexus 5 home button is misplaced to the right side of the actionbar. You can see it from the images. Has anyone came up to this problem?
Thank you.
Other devices (Such as Nexus 4, Samsung Galaxy S4 etc.)
Nexus 5
For showing custom home button I'm am using
actionBar.setDisplayShowCustomEnabled(true);
I was using RelativeLayout
for my custom view and I think it was causing the problem I had. I switched it with LinearLayout
and set some properties and my problem solved. These properties are
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
But still I didn't understand why it works well with other devices such as Samsung Galaxy S4, Nexus 4 etc. and not working well with Nexus 5 and Nexus 7.
Before I switched to LinearLayout
I tried various way to solve my problem including control for devices and settings margins programmatically.
For those still insist using RelativeLayout
for ActionBarSherlock customView you can use the workaround which I do not recommend.
if (Build.MODEL.contains("Nexus 5")) {
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.setMargins(-150, 0, 0, 0);
actionBar.setCustomView(v, params);
}
这篇关于动作条home键是Nexus 5的错位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!