在我的應用程序中,我想將填充應用於主題中的所有屏幕頂級容器。將填充/邊距設置爲主題中的頂部活動/分段佈局容器?
示例:
這裏是佈局文件。
<?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>
這裏是應用程序的主題。
<!-- 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>
我可以使用android:padding
應用填充到父容器RelativeLayout。但我不想這樣,因爲我需要在每個佈局文件中指定相同的內容,所以我想在主題--AppTheme中定義它。
任何解決方案,將不勝感激。
創建填充佈局和重新使用它在任何你想要http://developer.android.com/training/improving-layouts/reusing- layouts.html –
我在問關於可重用的佈局,關於主題 –