cocosCreator安卓隐私弹窗(链接版)

发布于:2025-04-17 ⋅ 阅读:(25) ⋅ 点赞:(0)

每次新上游戏都要重新弄这个隐私弹窗,记录一下下次直接抄。

一、创建Activity

1 用androidStudio 打开项目并切换到Android视角。
2 右键项目new一个空的Activity
3 修改Activity的名字并完成如下图
在这里插入图片描述

二、增加依赖文件

·1 增加全局颜色定义文件:项目根目录 / res/values/ colors.xml这里是弹窗需要的颜色定义

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 这里我们取主场景的背景色 -->
    <color name="splashBg">#DA8020</color>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
    <color name="colorWhite">#FFFFFFFF</color>
    <color name="colorBlack">#FF000000</color>
    <color name="colorGray">#878787</color>
    <color name="colorOrange">#FFE26C25</color>
    <color name="colorBlue">#FF036EB8</color>
</resources>

2、增加string内容:app/src/main/res/values/strings.xml 这是弹窗需要的文字定义

<resources>
    <string name="privacy_exit" translatable="false">退出</string>
    <string name="privacy_agree" translatable="false">同意</string>
    <string name="privacy_title" translatable="false">隐私协议</string>
    <string name="privacy_yszc" translatable="false">https://www.csdn.com/</string>
    <string name="privacy_text" translatable="false">您需要同意用户协议与隐私政策后才能继续使用本游戏。您可阅读和了解详细信息。</string>
    <string name="privacy_text_last" translatable="false">如您同意请点击“同意”开始接受我们的服务。</string>
</resources>

三、编写弹窗布局文件

位置:app/src/main/res/layout/activity_first.xml
直接复制以下内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_content_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">
    <!--android:background 对话框背景布局-->

    <!--隐私协议标题-->
    <TextView
        android:id="@+id/tv_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:gravity="center"
        android:paddingTop="20dp"
        android:textSize="16sp"
        android:textStyle="bold" 
        android:text="@string/privacy_title"
        android:textColor="@color/colorWhite"
        >
        
        </TextView>
    <!--隐私协议内容-->
    <TextView
        android:id="@+id/tv_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="6dp"
        android:paddingRight="12dp"
        android:paddingBottom="2dp"
        android:tag="{'linkColor':'#FF00FF','linkLine':false}" 
        android:text="@string/privacy_text"> 
    </TextView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="2dp"
        android:paddingRight="12dp"
        android:paddingBottom="8dp">

        <TextView
            android:id="@+id/web_yszc"
            android:layout_width="183dp"
            android:layout_height="wrap_content"
            android:paddingLeft="12dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:paddingBottom="10dp"
            android:textColor="@color/colorOrange" />

        <TextView
            android:id="

网站公告

今日签到

点亮在社区的每一天
去签到