问题
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