android实现去掉任务栏或全屏显示

y 王军 , 2010年06月22日 5:34 下午

  由于手机的屏幕很小,有时候为了显示更多内容需要去除手机上方的任务栏或去除所有信息,全屏显示内容,效果如下:

image image

实现代码如下:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         //图一的效果

        requestWindowFeature(Window.FEATURE_NO_TITLE);

       //图二的效果
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        setContentView(R.layout.pblogin);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现WinForm窗口全屏显示并隐藏下方任务栏,我们可以按照以下步骤进行操作: 1. 将窗口的BorderStyle属性设置为None,这样可以去掉窗口的标题栏和边框。 2. 使用窗口的WindowState属性将窗口最大化,即将其状态设置为Maximized。 3. 在窗口加载时,使用Screen类的PrimaryScreen属性获取主屏幕的大小信息。 4. 获取任务栏的高度,可以使用Screen类的WorkingArea属性的Height属性减去Screen类的PrimaryScreen属性的Height属性来计算。 5. 将窗口的Height属性设置为主屏幕的Height减去任务栏的高度,这样窗口就可以全屏显示了。 6. 在窗口的VisibleChanged事件中,使用Win32 API函数FindWindow和ShowWindow来隐藏任务栏。 下面是示例代码,实现了窗口全屏显示并隐藏任务栏: ```c# using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace FullScreenApp { public partial class MainForm : Form { // 引入Win32 API函数 [DllImport("user32.dll")] private static extern IntPtr FindWindow(string className, string windowName); [DllImport("user32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); // 窗口消息常量 private const int SW_HIDE = 0; private const int SW_SHOW = 1; public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { // 窗口最大化 WindowState = FormWindowState.Maximized; // 获取主屏幕大小和任务栏高度 int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeight = Screen.PrimaryScreen.Bounds.Height; int taskbarHeight = Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height; // 全屏显示窗口 Height = screenHeight - taskbarHeight; } private void MainForm_VisibleChanged(object sender, EventArgs e) { // 隐藏任务栏 IntPtr taskbarHandle = FindWindow("Shell_TrayWnd", null); ShowWindow(taskbarHandle, SW_HIDE); } } } ``` 使用以上的代码和步骤,我们就可以将WinForm窗口全屏显示,并在显示窗口时隐藏下方任务栏
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值