0
我添加了一个自定义标题栏使用下面的代码howeveri似乎有大约10像素左右间距左右2px在底部,是他们无论如何,我可以使自定义标题栏适合titlbar区域?自定义标题栏不填充标题栏区域
感谢您的任何意见
乔纳森
customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.tab);
Display display = getWindowManager().getDefaultDisplay();
if (customTitleSupported) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.titlebar);
LinearLayout titlebar = (LinearLayout) findViewById(R.id.TitleBarLayOut);
titlebar.setPadding(-2, -1, -2, -1);
titlebar.setMinimumWidth(display.getWidth());
GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
new int[] {Color.RED, Color.YELLOW}
);
titlebar.setBackgroundDrawable(grad);
playButton = new Button(this);
playButton.setText("Play");
playButton.setGravity(Gravity.LEFT);
infoButton = new Button(this);
infoButton.setText("Info");
infoButton.setGravity(Gravity.RIGHT);
titlebar.addView(playButton, new LinearLayout.LayoutParams(
70,1));
titlebar.addView(infoButton, new LinearLayout.LayoutParams(
70,1));
}
<?xml version="1.0" encoding="utf-8"?>
对不起,我没有意识到我的布局xml hadnt张贴。我有宽度设置为填写父母 –
我不知道。尝试删除MinWidth和填充? –