2016-04-21 61 views
-2

我正在使用活动来作为对话框工作。但是,对话框活动的actionBar不会消失。我曾尝试使用:对话框活动中消失的动作栏

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 

    setContentView(R.layout.activity_dialog); 

} 

它不起作用。我还设置了应用程序(从清单)的主题是如下:

<activity 
     android:name=".DialogActivity" 
     android:label="@string/title_activity_dialog" 
     android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" > 
    </activity> 

以下是屏幕截图就是我得到的和我的目标,以去除隐藏着这个毫无意义的白条文本。 The Screen Shot of the Emulator

谢谢。

回答

0

虽然在理论上定制与没有标题栏的主题应该工作,但是在我的情况没有奏效。所以,我解决它从activity_ 的.xml

 <android.support.v7.widget.Toolbar android:id="@+id/toolbar" 
      android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 
1

创建自定义主题,例如。 CustomTheme在styles.xml

<style name="CustomTheme" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowActionBar">false</item> 
</style> 

和使用manifest.xml中

android:theme="@style/CustomTheme" 
+0

喜删除以下部分,感谢您的及时回复。我尝试了上面提到的更改并仍然显示栏:/。 –

+0

请尝试编辑答案。 – user2925656

+0

我想可能还有其他一些我看不到的问题。活动(用于对话框)是否为空或空? 。 –

0

试试这个:

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog"> 
    <item name="colorPrimary">@color/primary</item> 
    <item name="colorPrimaryDark">@color/primary_dark</item> 
    <item name="colorAccent">@color/accent</item> 
    <item name="windowNoTitle">true</item>