简体   繁体   English

设备主页中的 Android 屏幕

[英]Android screen in the home of the device

How can I create a similar thing for android?如何为android创建类似的东西?

In short, when you click on the app icon, this window opens.简而言之,当您单击应用程序图标时,会打开此窗口。

I tried to look, but I do not know what term to use to find a basic example.我试着看,但我不知道用什么术语来找到一个基本的例子。

Some advice?一些忠告?

To create a transparent activity.创建一个透明的活动。 Create a custom style in style.xml as below;在 style.xml 中创建自定义样式,如下所示;

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="Theme.AppCompat.Transparent.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">true</item>
</style>

And use it in your Manifest.xml application or activity section并在您的 Manifest.xml 应用程序或活动部分使用它

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.Transparent.NoActionBar">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Then, of course, you need to create a layout with a background color at the center of activity and put your views in it.然后,当然,您需要在活动的中心创建一个带有背景颜色的布局,并将您的视图放入其中。

Hope it helps希望能帮助到你

这是一个由服务支持的浮动视图(因为它不是应用程序主要活动流的一部分)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM