我用我的风格改变了android:background:
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">#747474</item>
<item name="colorControlActivated">@color/colorAccentTrans</item>
<item name="colorControlHighlight">@color/colorAccentTrans</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:background">@color/background</item>
</style>
现在像我的素材日历视图这样的元素似乎有很多可见性,我无法弄清楚原因。
这里是片段布局的XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
tools:context="io.rocketfox.dreamydiary.JournalView">
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_nothingInList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/background"
android:padding="0dp"
android:visibility="invisible"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="50dp">
<ImageView
android:id="@+id/img_NoDreamsHint"
android:layout_width="167dp"
android:layout_height="115dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="false"
android:cropToPadding="true"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.39999998"
app:srcCompat="@drawable/sheep" />
<TextView
android:id="@+id/txt_NoDreamsHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:text="No dreams yet"
android:textColor="@color/splashScreenAction"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_NoDreamsHint" />
</android.support.constraint.ConstraintLayout>
<RelativeLayout
android:id="@+id/layout_calendarPicker"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mcv_allowClickDaysOutsideCurrentMonth="true"
app:mcv_arrowColor="@color/cardview_light_background"
app:mcv_dateTextAppearance="@style/CustomTextAppearanceDates"
app:mcv_firstDayOfWeek="monday"
app:mcv_headerTextAppearance="@style/CustomTextAppearanceMonth"
app:mcv_selectionColor="@color/colorAccentTrans"
app:mcv_tileSize="40dp"
app:mcv_tileWidth="50dp"
app:mcv_weekDayTextAppearance="@style/CustomTextAppearanceWeek"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="81dp" />
<ListView
android:id="@+id/listDreams"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/calendarView"
android:background="@color/background" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_AddDream"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@drawable/add" />
</RelativeLayout>
</RelativeLayout>
Fab Button是唯一可见的东西。
背景更改后布局的屏幕截图:http://imgur.com/ElraxNw
答案 0 :(得分:1)
我自己解决了这个问题:我的问题是片段转换之间由于渲染和底层背景颜色而出现白色背景。 我需要添加到样式的是不
<item name="android:background">color here</item>
相反,我必须编辑
<item name="android:windowBackground">color here</item>
这解决了这个问题。
答案 1 :(得分:1)
android:windowBackground
代替android:background
windowBackground
是仅在以下情况下有效的样式属性 该样式将作为主题应用于Activity
或application
和android:windowBackground
属性仅支持对引用 另一种资源。
FAB
,因为FAB
的容器是RelativeLayout
,其width
和height
是match_parent
。这就是为什么它与您的layout_calendarPicker
重叠。更新您的布局XML,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_nothingInList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/background"
android:padding="0dp"
android:visibility="invisible"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="50dp">
<ImageView
android:id="@+id/img_NoDreamsHint"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="false"
android:cropToPadding="true"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.39999998"
app:srcCompat="@drawable/sheep" />
<TextView
android:id="@+id/txt_NoDreamsHint"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:text="No dreams yet"
android:textColor="@color/splashScreenAction"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_NoDreamsHint" />
</android.support.constraint.ConstraintLayout>
<RelativeLayout
android:id="@+id/layout_calendarPicker"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mcv_allowClickDaysOutsideCurrentMonth="true"
app:mcv_arrowColor="@color/cardview_light_background"
app:mcv_dateTextAppearance="@style/CustomTextAppearanceDates"
app:mcv_firstDayOfWeek="monday"
app:mcv_headerTextAppearance="@style/CustomTextAppearanceMonth"
app:mcv_selectionColor="@color/colorAccentTrans"
app:mcv_tileSize="40dp"
app:mcv_tileWidth="50dp"
app:mcv_weekDayTextAppearance="@style/CustomTextAppearanceWeek"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="81dp" />
<ListView
android:id="@+id/listDreams"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/calendarView"
android:background="@color/background" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_AddDream"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:clickable="true"
android:src="@drawable/add" />
</RelativeLayout>
</RelativeLayout>
希望这会有所帮助〜