Yakuza
Yakuza

Reputation: 53

How to change primary and primaryDark color?

current layout

main layout view image

I have a problem related to xml layout, and I don't know how to add primary and primary dark color. Can anybody help me?

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
      <ListView android:id="@+id/in"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:stackFromBottom="true"
                android:transcriptMode="alwaysScroll"
                android:layout_weight="1"/>

      <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText android:id="@+id/edit_text_out"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:layout_gravity="bottom"/>
        <Button android:id="@+id/button_send"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/send"/>
    </LinearLayout>
</LinearLayout>  

How it should look like

Need this layout

Upvotes: 2

Views: 18178

Answers (2)

sud
sud

Reputation: 505

Do you mean you need to change the color of action bar located at top most position right? Then do this: so, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3).

Just in case, if you target for minimum API level 11, you can change ActionBar's background color by defining custom style, as:

<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>

And, set "MyTheme" as theme for application/activity.

Upvotes: -1

Adrien Chapelet
Adrien Chapelet

Reputation: 450

You should modify, or create if it didn't exists already the file styles.xml, in the values folder, like that :

<style name="MyMaterialTheme.Base" >
    <!--   Primary Color -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="colorAccent">@color/colorAccent</item>
</style>

It gets it's values from colors.xml file.

Upvotes: 6

Related Questions