问题
i want to set my Activity full Screen with Title bar , how can i do this ? thanks
回答1:
In styles.xml:
<resources>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Refer to your custom style in your mainfest:
<activity android:name=".MyActivity" android:theme="@style/Theme.FullScreen"/>
To be truthful I've not tested this combination myself.
回答2:
This worked for me:
// Remove System bar (and retain title bar)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
In code it would look like this:
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class ActivityName extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Remove System bar (and retain title bar)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Set your layout
setContentView(R.layout.main);
}
}
回答3:
To create a full screen app with a custom title style, override some attributes of a full screen theme like so:
<style name="AppTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
<item name="android:windowNoTitle">false</item>
<item name="android:windowTitleSize">45dip</item>
<item name="android:windowTitleBackgroundStyle">@style/TitleBackgroundStyle</item>
</style>
<style name="TitleBackgroundStyle">
<item name="android:background">@drawable/title</item>
</style>
and modify as you wish.
回答4:
I suggest you to set fullscreen theme for activity e.g. Theme.Black.NoTitleBar.Fullscreen and create custom title bar in activity layout.
回答5:
Set your App theme as Theme.Holo.Compactmenu to make your title bar visible along with the icon
来源:https://stackoverflow.com/questions/12754897/android-full-screen-activity-with-title-bar