android常用知识

透明activity样式:

android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

这句代码,当你是建的empty activity project时,默认继承的是AppCompat这个类。所以在AndroidMifext.xml文件中用上述代码会导致程序错误,打不开,不清楚具体是什么原因。如果你的activity是继承Activity,应该不会这样。

解决办法:自定义透明样式

在res-theme-theme.xml文件中添加样式:

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

然后在AndroidManifext.xml文件中引用即可。

透明是什么意思?假如你的布局文件空空如何,那么就相当于铺上了一层透明的纸。

假如你的布局文件中有按钮,文本等控件,那么你的控件其实是在这张透明的纸上,纸透明,看起来的效果就是与底层的图标交错覆盖,类似这种:

此时你点击图标是没用的,因为有透明 的纸挡着呢!!

service中启动新的activity:

 Intent intent3 = new Intent(getApplicationContext(), MainActivity2.class);
        intent3.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent3);

service中启动其他软件,指定目标软件的activity:

Intent intent2 = new Intent();
        intent2.setClassName("com.example.demob", "com.example.demob.MainActivity");
        intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent2);

广播接收者打开后台服务:

Intent serviceIntent = new Intent(MainActivity.this, MyService.class);
                startService(serviceIntent);

在有UI的android程序中,

相关推荐

  1. android

    2024-06-18 21:32:01       48 阅读
  2. Android命令

    2024-06-18 21:32:01       54 阅读
  3. android方法

    2024-06-18 21:32:01       69 阅读
  4. android 工具

    2024-06-18 21:32:01       27 阅读
  5. android技术整理

    2024-06-18 21:32:01       66 阅读
  6. Android 国内镜像

    2024-06-18 21:32:01       42 阅读
  7. Android adb 命令

    2024-06-18 21:32:01       40 阅读
  8. Android命名大全

    2024-06-18 21:32:01       32 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-18 21:32:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-18 21:32:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-18 21:32:01       82 阅读
  4. Python语言-面向对象

    2024-06-18 21:32:01       91 阅读

热门阅读

  1. Flink 计数器Accumulator

    2024-06-18 21:32:01       29 阅读
  2. MySQL触发器基本结构

    2024-06-18 21:32:01       28 阅读
  3. Roboflow对YOLO数据集、标注、训练、下载

    2024-06-18 21:32:01       27 阅读
  4. Bean 的生命周期

    2024-06-18 21:32:01       33 阅读
  5. web前端开发哪个城市:探索最佳发展地

    2024-06-18 21:32:01       31 阅读
  6. Linux中的进程控制

    2024-06-18 21:32:01       35 阅读
  7. 高并发系统中面临的问题 及 解决方案

    2024-06-18 21:32:01       30 阅读
  8. Vue 3 的 setup 函数使用及避坑指南

    2024-06-18 21:32:01       31 阅读
  9. leetcode-11-二叉树前中后序遍历以及层次遍历

    2024-06-18 21:32:01       30 阅读
  10. API接口被刷 如何解决

    2024-06-18 21:32:01       25 阅读
  11. 机器学习中的神经网络入门

    2024-06-18 21:32:01       34 阅读
  12. C++中的访问者模式

    2024-06-18 21:32:01       28 阅读
  13. 双指针练习:和为s的两个数字

    2024-06-18 21:32:01       29 阅读
  14. CVPR2024 分割Segmentation相关论文37篇速览

    2024-06-18 21:32:01       22 阅读