I want to set all activity same gradient.
Is it possible?How?
Is it possible?How?
ok theni don´t think so.
how to do this?You need to use the same code in any Activity to do so.
Add the same code to activity X like you did for Main activity where i expect it you already have it like you want.how to do this?
this is suitableAlternatively you can use create a Class to do it and use this class in all activities.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#3B5998"
android:endColor="#00000000"
android:angle="45"/>
</shape>
@Semen Matusovskiy : I think you are a genius, but sometimes it is hard to understand your answers. You need to come down a little bit to our level. Where does the line:<item name="android:windowBackground">@drawable/mygradient</item>
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#0098FF</item>
<item name="colorPrimaryDark">#007CF5</item>
<item name="colorAccent">#AAAA00</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
)
I am not interested in Erel's sample. I want to add it to a default manifest as I showed in post #9Download well-known Erel's sample
CreateResource(values-v14, theme.xml,
<resources>
<style name="DarkTheme" parent="@android:style/Theme.Holo">
<item name="android:windowBackground">@drawable/mygradient</item>
</style>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
<style name="DarkTheme" parent="@android:style/Theme.Material">
<item name="android:windowBackground">@drawable/mygradient</item>
</style>
</resources>
)
Now you are cooking. is there a way to apply the gradient drawable using the manifest to all buttons in the parent for example , not just the activity?Well, let's look empty project
CreateResource (drawable, mygradient.xml,
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:angle="90" android:endColor="#4a80ec" android:startColor="#14316b" android:type="linear" />
</shape>
)
CreateResource (drawable, mybutton.xml,
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:angle="90" android:startColor="#c25e00" android:endColor="#fb8c00" />
</shape>
</item>
<item>
<shape>
<gradient android:angle="90" android:endColor="#ff009f" android:startColor="#1a2b5d" />
</shape>
</item>
</selector>
)
CreateResource (values-v14, theme.xml,
<resources>
<style name="DarkTheme" parent="@android:style/Theme.Holo">
<item name="android:windowBackground">@drawable/mygradient</item>
<item name="android:buttonStyle">@style/ButtonAppTheme</item>
</style>
<style name="ButtonAppTheme" parent="android:Widget.Holo.Button">
<item name="android:background">@drawable/mybutton</item>
</style>
</resources>
)
CreateResource (values-v20, theme.xml,
<resources>
<style name="DarkTheme" parent="@android:style/Theme.Material">
<item name="android:windowBackground">@drawable/mygradient</item>
<item name="android:buttonStyle">@style/ButtonAppTheme</item>
</style>
<style name="ButtonAppTheme" parent="android:Widget.Material.Button">
<item name="android:background">@drawable/mybutton</item>
</style>
</resources>
)