Regarding removal of Activity Title bar in Android

青春壹個敷衍的年華 提交于 2019-12-22 05:41:47

问题


i have already set the theme of my activity as android:theme = "@android:style/Theme.Dialog" but i also want to remove the title bar of the activity. so how to use android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" along with the dialog theme.


回答1:


Try creating a custom style that extends Theme.Dialog:

<resources>
    <style name="DialogNoTitle" parent="android:Theme.Dialog">
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>



回答2:


I believe you can specify this in your activity's onCreate():

requestWindowFeature(Window.FEATURE_NO_TITLE);



回答3:


For AppCompat, following solution worked for me:

Add new theme style with no action bar in your styles.xml and set parent="Theme.AppCompat.NoActionBar".

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorPrimary</item>

</style>


Now implement the same theme style to your splash screen activity in androidManifest.xml

<activity
        android:name=".ActivityName"
        android:theme="@style/SplashTheme"> // apply splash them here 

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

Here is result:



来源:https://stackoverflow.com/questions/4171742/regarding-removal-of-activity-title-bar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!