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和填充? –