1

我想要做的是当用户在我的应用程序中编辑文本时隐藏自定义标题栏,以便为他提供更广阔的视野。我可以很好地空白标题栏中的元素,但这只会腾出空间;我正在尝试使应用程序窗口扩展以动态利用该空间。

我已经设置了一个自定义标题栏,它是我的应用导航不可或缺的。它允许用户在片段之间跳转。我只是想暂时隐藏标题栏。

我正在使用以下自定义主题:

<style name="GTTheme2" parent="@android:style/Theme.Holo">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowTitleSize">37dp</item>
    <item name="android:windowSoftInputMode">adjustResize</item>
</style>

在我的活动中,我有。

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.gtDisplay);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_gt_phone);

我试过以下

 getActivity().getActionBar().hide();

That returns a null pointer exception because the action bar doesn't exist because I set up a custom title. I tried setting "Android:windowActionBar" to true my theme, but apparently the setting conflicts with setting up a custom title bar, as my app failed to load.

I also tried

getActivity().setTheme( <<some new theme here>>);

Where the new theme didn't have a title or had 0dp for windowTitleSize, but screen didn't change.

Tried searching if there is a way to set windowTitleSize dynamically (other than as a startup theme in AndroidMainfest) but haven't found anything. Any thoughts?

4

0 回答 0