1

我的 DialogActivity 扩展自 SherlockFragmentActivity。所以我必须使用 Sherlock 主题。在values-v14我隐藏这样的标题:

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

如何Theme.Sherlock.Dialogvalues文件夹中隐藏标题?

默认情况下,它看起来像这样(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>
4

1 回答 1

2

解决方案:abs__dialog_title_holo.xml通过在以下位置添加两行进行了更改:https ://github.com/JakeWharton/ActionBarSherlock/blob/master/library/res/layout/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>

于 2013-04-13T14:51:20.140 回答