Ali Soleymani Roozbahani Ali Soleymani Roozbahani - 21 days ago 7
Android Question

Color Primary Dark is not working

i set the color primary dark before in my color.xml file and the status bar color was the same color that color primary dark was too! but a few hours ago, i made a menu resource file and for creating a search button in my toolbar!. when i run my code, i saw that the color primary dark disappeared and is not working . i search a lot to understand what is the problem but i did not find any thing. please guide me to fix this problem.
thanks in advanced

style.xml:


<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">

</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

</style>




style-v21 :



<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="android:windowTranslucentStatus">true</item>
<item name="android:navigationBarColor">@color/colorNavBar</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>




toolbar.xml :

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="?attr/colorPrimary"
android:layout_gravity="start">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toolbar_title"
android:text="@string/app_name_persian"
android:textSize="19sp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:layout_gravity="right"/>
<EditText
android:layout_marginRight="20dp"
android:id="@+id/searchEditText"
android:layout_width="180dp"
android:textSize="10sp"
android:hint="@string/search_hint"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible"/>




color.xml :

<resources>
<color name="colorPrimary">#0cac77</color>
<color name="colorPrimaryDark">#73ac95</color>
<color name="colorAccent">#20efd6</color>
<color name="colorNavBar">#73ac95</color>
<color name="colorNavDrawerBackColor">#f4f3f3</color>
<color name="colorCreationDate">#4acc82</color>
<color name="colorDeadDate">#d77177</color>
<color name="colorDutyName">#e5e8e9</color>



Answer

i found the answer! i used android:fitsSystemWindows="true" in the root layout's attributes in main activity's xml to avoiding window movement when the user is typing with keypad, but i fixed it with putting this android:windowSoftInputMode="adjustPan" in activity's attributes in Manifest file! thanks guys for answering my question.

Comments