小编Mah*_*nde的帖子

将填充/边距设置为主题中顶部的活动/片段布局容器?

在我的应用程序中,我想将填充应用于主题的所有屏幕顶级容器。

例如:

这是布局文件。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/edt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是应用程序主题。

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowFrame">@drawable/window_frame</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

我可以android:padding对父容器RelativeLayout 使用padding 。但是我不想这样,因为我需要在每个布局文件中指定相同的内容,我想在主题-AppTheme中进行定义。

任何解决方案将不胜感激。

android android-layout android-activity

5
推荐指数
1
解决办法
3088
查看次数

标签 统计

android ×1

android-activity ×1

android-layout ×1