【发布时间】:2013-03-19 05:08:00
【问题描述】:
我正在向标题标题添加一个自定义 img,但无论我做什么,我仍然在 img 的每一侧都有一个小间隙(也显示在这个 question 中)
这是我的 strings.xml 文件中的 xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello"></string>
<string name="app_name"></string>
<style name="LargeTitleTheme" parent="android:Theme.Light">
<item name="android:windowTitleSize">44dip</item>
</style>
</resources>
这是我活动中的代码(此时忽略草率 - 绝望的编码)
ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView();
LinearLayout root = (LinearLayout) decorView.getChildAt(0);
FrameLayout titleContainer = (FrameLayout) root.getChildAt(0);
TextView title = (TextView) titleContainer.getChildAt(0);
title.setGravity(Gravity.CENTER);
Drawable drawable = getResources().getDrawable(R.drawable.nav);
drawable.setBounds(0,0,0,0);
title.setBackgroundDrawable(drawable);
title.setPadding(0,0,0,0);
title.setIncludeFontPadding(false);
【问题讨论】: