出于某种原因,我的MainActivity工具栏再次出现(在我从我的应用程序中删除了所有工具栏之后),灰色(应用程序的其余部分为蓝色)。我想在xml中删除它,布局主题与应用程序的其余部分完全相同。这就是为什么我不确定什么是错的,并且无法在线找到任何解决方案。
样式:
<style id="checkBoxStyle" name="checkBoxStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColorSecondary">#dc302e2e</item>
<item name="android:editTextColor">#000000</item>
</style>
MainActivity布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="@drawable/weakbeach"
android:theme="@style/checkBoxStyle"
tools:context="com.example.itay.newfrindlyalarm.MainActivity"
android:focusableInTouchMode="true">
<Button
android:id="@+id/buttonSetting"
android:layout_width="192dp"
android:layout_height="wrap_content"
android:background="#1a6ca3"
android:text="Settings"
android:textAllCaps="true"
android:textColor="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="32dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<Button
android:id="@+id/button_add_alarm"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:background="@color/ligthSec"
android:text="Add new Alarm:"
android:textAllCaps="true"
android:textColor="#ffffff"
android:textSize="20dp"
app:layout_constraintLeft_toLeftOf="@+id/buttonSetting"
app:layout_constraintRight_toRightOf="@+id/buttonSetting"
app:layout_constraintTop_toBottomOf="@+id/alarmMessage" />
<TimePicker
android:id="@+id/alarmTimePicker"
android:layout_width="200dp"
android:layout_height="144dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:timePickerMode="spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.00999999"></TimePicker>
<ImageView
android:id="@+id/imageView"
android:layout_width="65dp"
android:layout_height="75dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintBottom_toTopOf="@+id/checkBoxDay4"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/alarmclock" />
<CheckBox
android:id="@+id/checkBoxDay2"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="M"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/checkBoxDay4" />
<CheckBox
android:id="@+id/checkBoxDay7"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="S"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay6"
app:layout_constraintLeft_toRightOf="@+id/checkBoxDay6"
app:layout_constraintRight_toRightOf="parent" />
<CheckBox
android:id="@+id/checkBoxDay1"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="S"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/checkBoxDay2" />
<CheckBox
android:id="@+id/checkBoxDay6"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="F"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay5"
app:layout_constraintLeft_toRightOf="@+id/checkBoxDay4"
app:layout_constraintRight_toRightOf="parent" />
<CheckBox
android:id="@+id/checkBoxDay5"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="T"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay4"
app:layout_constraintLeft_toRightOf="@+id/checkBoxDay4"
app:layout_constraintRight_toLeftOf="@+id/checkBoxDay6" />
<CheckBox
android:id="@+id/checkBoxDay4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:checked="false"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="W"
app:layout_constraintHorizontal_bias="0.56"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/alarmTimePicker" />
<CheckBox
android:id="@+id/checkBoxDay3"
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:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:text="T"
app:layout_constraintBaseline_toBaselineOf="@+id/checkBoxDay4"
app:layout_constraintLeft_toRightOf="@+id/checkBoxDay2"
app:layout_constraintRight_toLeftOf="@+id/checkBoxDay4" />
<ToggleButton
android:id="@+id/repeateButton"
android:layout_width="88dp"
android:layout_height="83dp"
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:background="@null"
android:gravity="bottom"
app:layout_constraintBottom_toTopOf="@+id/checkBoxDay1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/alarmTimePicker"
app:layout_constraintTop_toTopOf="parent"
android:drawable="@drawable/chenge_image_repeat"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.122" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/chenge_image_repeat"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintRight_toRightOf="@+id/repeateButton"
app:layout_constraintLeft_toLeftOf="@+id/repeateButton" />
<EditText
android:id="@+id/alarmMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:maxLength="32"
android:inputType="textPersonName"
android:text=""
android:hint="Enter Your Alarm message here"
android:textColorHint="#767373"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBoxDay4" />
<android.support.v7.widget.RecyclerView
android:id="@+id/alarm_list"
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"
app:layout_constraintBottom_toTopOf="@+id/buttonSetting"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_add_alarm"
app:layout_constraintVertical_bias="0.0">
</android.support.v7.widget.RecyclerView>
<Spinner
android:id="@+id/ringtonesSpinner"
android:layout_width="69dp"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="194dp" /><![CDATA[
;
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:layout_editor_absoluteY="32dp" />
]]>
</android.support.constraint.ConstraintLayout>
另一个活动布局(删除工具栏,颜色为蓝色):
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:background="@drawable/cute_dog_n_pinguin"
android:layout_width="match_parent"
android:theme="@style/checkBoxStyle"
android:layout_height="match_parent"
tools:context="com.example.itay.newfrindlyalarm.AlarmSettings">
<TextView
android:id="@+id/textView_snozee_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snooze Settings:"
android:textColor="@color/greySettings"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginStart="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="32dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.15"
android:layout_marginEnd="8dp" />
<Switch
android:id="@+id/switch_snooze"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="snooze on: "
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/textView_snozee_settings"
android:layout_marginLeft="24dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="24dp" />
<TextView
android:id="@+id/textView_snooze_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snooze time:"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="#000000"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/switch_snooze"
android:layout_marginLeft="24dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="24dp" />
<CheckBox
android:id="@+id/checkBox_5"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:textColor="#000000"
app:layout_constraintLeft_toRightOf="@+id/checkBox_3"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
app:layout_constraintBottom_toBottomOf="@+id/checkBox_3"
app:layout_constraintTop_toTopOf="@+id/checkBox_3" />
<CheckBox
android:id="@+id/checkBox_7"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:textColor="#000000"
app:layout_constraintLeft_toRightOf="@+id/checkBox_5"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
app:layout_constraintBottom_toBottomOf="@+id/checkBox_5"
app:layout_constraintTop_toTopOf="@+id/checkBox_5" />
<CheckBox
android:id="@+id/checkBox20"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:textColor="#000000"
app:layout_constraintLeft_toLeftOf="@+id/checkBox_7"
app:layout_constraintBottom_toBottomOf="@+id/checkBox15"
app:layout_constraintTop_toTopOf="@+id/checkBox15" />
<CheckBox
android:id="@+id/checkBox15"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15"
android:textColor="#000000"
app:layout_constraintLeft_toLeftOf="@+id/checkBox_5"
app:layout_constraintBottom_toBottomOf="@+id/checkBox10"
app:layout_constraintTop_toTopOf="@+id/checkBox10" />
<CheckBox
android:id="@+id/checkBox10"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="15dp"
android:text="10"
android:textColor="#000000"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_3"
android:layout_marginStart="12dp" />
<CheckBox
android:id="@+id/checkBox_3"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textColor="#000000"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/textView_snooze_time"
app:layout_constraintLeft_toLeftOf="@+id/checkBox10" />
<Button
android:id="@+id/buttonRingtone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Ringtone"
android:textColor="#d4d4d4"
android:layout_marginLeft="24dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/checkBox15"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.00999999" />
</android.support.constraint.ConstraintLayout>
我确信解决方案很简单,我只是浪费了3个小时试图解决它。非常感谢!
编辑: 我添加了一些图片: MainActivity
答案 0 :(得分:2)
try this one
<style name="AppTheme.FullScreen">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
答案 1 :(得分:0)
感谢您的帮助,但问题出现在Manifest中。 我需要为Manifest中的活动选择正确的主题,而不是在xml文件中 (相关的清单部分):
<activity android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>