You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OssLicensesActivity中ActionBar遮挡内容的解决方法求助

解决OssLicensesActivity ActionBar遮挡许可证文本的问题

针对Android 15设备上OssLicensesActivity的ActionBar遮挡许可证文本的问题,可以尝试以下几种解决方案:

方案1:调整主题属性,禁用ActionBar覆盖内容

修改themes.xml中的OSSLicensesTheme,添加禁止ActionBar覆盖内容的属性,同时适配Android 15的窗口布局规则:

<style name="OSSLicensesTheme" parent="Theme.Material3.Light">
    <item name="android:textColor">@color/black</item>
    <item name="android:textColorLink">@color/purple_700</item>
    <!-- 禁止ActionBar覆盖内容区域,确保文本从ActionBar下方开始布局 -->
    <item name="android:windowActionBarOverlay">false</item>
    <!-- Android 15+ 适配:让系统自动处理内容与系统栏的间距 -->
    <item name="android:windowDecorFitsSystemWindows">true</item>
</style>

方案2:自定义布局添加顶部内边距

如果主题调整无效,可以自定义OssLicensesActivity的布局,手动添加与ActionBar高度匹配的顶部内边距:

  1. 创建布局文件res/layout/activity_oss_licenses.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    <!-- 引用ActionBar高度作为顶部内边距,确保文本避开ActionBar -->
    android:paddingTop="?attr/actionBarSize">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/licenses_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="16dp"
            android:textColor="@color/black"
            android:textColorLink="@color/purple_700"/>
    </ScrollView>
</LinearLayout>
  1. 在AndroidManifest.xml中为OssLicensesActivity指定该布局:
<activity
    android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
    android:theme="@style/OSSLicensesTheme"
    android:exported="false"
    android:layout="@layout/activity_oss_licenses"> <!-- 添加布局引用 -->
    <meta-data
        android:name="android.app.lib_name"
        android:value="" />
</activity>

方案3:切换为无ActionBar主题并自定义Toolbar

如果前两种方法都不生效,可以改用无ActionBar的主题,自行添加Toolbar来控制布局结构:

修改themes.xml:

<style name="OSSLicensesTheme" parent="Theme.Material3.Light.NoActionBar">
    <item name="android:textColor">@color/black</item>
    <item name="android:textColorLink">@color/purple_700</item>
</style>

然后在自定义布局顶部添加Toolbar,内容区域会自然位于Toolbar下方,布局结构可参考方案2的自定义布局,补充Toolbar代码即可。

内容的提问来源于stack exchange,提问作者chwon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 20:45:03