如何隐藏`Theme.Sherlock.Dialog`中的标题?

时间:2013-04-11 21:07:51

标签: android dialog styles actionbarsherlock

我的DialogActivities从SherlockFragmentActivity扩展而来。所以我必须使用Sherlock主题。 在values-v14我隐藏标题,如下所示:

<style name="Theme.Sherlock.Dialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>

如何隐藏Theme.Sherlock.Dialog文件夹中values的标题?

默认情况下,它看起来像这样(github.com):

<style name="Theme.Sherlock.Dialog" parent="android:Theme">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowTitleStyle">@style/DialogWindowTitle.Sherlock</item>
    <item name="android:windowBackground">@drawable/abs__dialog_full_holo_dark</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>

    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">true</item>
    <item name="android:windowCloseOnTouchOutside">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimAmount">0.6</item>

    <item name="android:colorBackgroundCacheHint">@null</item>

    <item name="android:textColorPrimary">@color/abs__primary_text_holo_dark</item>
    <item name="android:textColorPrimaryInverse">@color/abs__primary_text_holo_light</item>

    <item name="windowMinWidthMajor">@dimen/abs__dialog_min_width_major</item>
    <item name="windowMinWidthMinor">@dimen/abs__dialog_min_width_minor</item>

    <item name="windowActionBar">false</item>
    <item name="windowContentOverlay">@null</item>
</style>

1 个答案:

答案 0 :(得分:2)

<强>解决方案: 我在https://github.com/JakeWharton/ActionBarSherlock/blob/master/library/res/layout/abs__dialog_title_holo.xml

中添加了两行来更改abs__dialog_title_holo.xml
<com.actionbarsherlock.internal.widget.FakeDialogPhoneWindow xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:fitsSystemWindows="true">
<TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:minHeight="@dimen/abs__alert_dialog_title_height"
    android:visibility="gone" //******** FIRST ******** 
    android:paddingLeft="16dip"
    android:paddingRight="16dip"
    android:gravity="center_vertical|left" />
<View android:id="@+id/abs__titleDivider"
        android:layout_width="fill_parent"
        android:visibility="gone" //******** SECOND ********
        android:layout_height="2dip"
        android:background="@color/abs__holo_blue_light" />
<FrameLayout
    android:layout_width="match_parent" android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical"
    android:foreground="?attr/windowContentOverlay">
    <FrameLayout android:id="@+id/abs__content"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
</FrameLayout>