How can I get rid of the gradient at the top of my screen (the very top of the blue in the screenshot below... below the notification bar)?
simple screenshot http://dl.dropbox.com/u/299320/device.png
This is themable; look at the windowContentOverlay attribute. In particular, you can create a new theme:
<style name="Theme.Foo" parent="android:style/Theme.Light">
<item name="android:windowContentOverlay">#null</item>
</style>
And then declare that your activity should use this theme:
<activity android:name=".FooActivity"
android:theme="#style/Theme.Foo"> ...
Although a better option is to set this theme for all activities in the application, for consistency:
<application android:theme="#style/Theme.Foo"> ...
Related
I used Android Studio to create basic activity using New -> Activity -> Basic Activity. But the activity background colour is black. I know it is to reduce battery consumption. But is there a way to change it to white colour, without changing style.
I tried to change the background colour of the root layout, but then it won't show hint text of edit text field. Because it's colour is white.
Then I tried to change theme from Material to Material Lite, then it wouldn't show the change when I run the app in the device.
Here is the activity declaration in AndroidManifest.xml
<activity
android:name=".SearchBus"
android:label="#string/title_activity_search_bus"
android:parentActivityName=".MapsActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="uk.co.stableweb.iroute.MapsActivity" />
</activity>
In your styles.xml set the android:windowBackground attribute for whatever theme you are using for application or activity. You can find the theme you are using in your AndroidManifest.xml.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">#color/somecolor</item>
</style>
</resources>
Note: If you have views in your layout that aren't transparent, it will block you from seeing the color you set here.
Did you try :android:background="#ffffff" i? It works for me
I have problem with circular reveal on my fragment. Whenever I call my reveal, it starts a new Activity and then inside onCreateView in fragment, it calls my reveal.
It works, but there is one glitch – as I start a new Activity, everything turns white. The Activity's background is white and covers data under it. Is it possible to show this data and not overlay it with this white background? Or should I make some kind of mask, animate it, and at the end start Activity?
I had the same issue and resolved it by using a transparent activity. To make your Activity transparent, use this code.
Theme Definition in styles.xml
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
Activity Definition in AndroidManifest.xml
<activity
android:name=".ui.CircularRevealActivity"
android:theme="#style/Theme.Transparent"
android:launchMode="singleTask"
/>
For a full answer on how to use a circular reveal animation on an activity, you can check this link.
I am looking for a way to slightly modify the default window title in an Android app for both phone and tablet. The example below is a tablet view of the title bar as standard:
I have tried implementing a custom title bar, which works but the context menu (circled in red) disappears, which I need. All I want to do is change the color of the bottom border or remove the bottom border altogether.
Is there a way to make changes whilst keeping the context menu?
Thanks
In your manifest in application tag define as :
android:theme="#style/mytheme"
Now in res/values you can define a file say theme.xml with content as :
<resources>
<style name="mytheme" parent="#android:style/Theme" >
<item name="android:_DEFAULT_BASE_COLOR_1">#XXXXXX</item>
<item name="android:windowNoTitle">true</item>
... .
</style>
</resources>
This will change the basic colour scheme of your application. Here are the color themes primarily used on Android: http://developer.android.com/design/style/color.html
Currently, I'm using this to show my application background as phone wallpaper.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
But for some reason when I start my application by pressing the icon. It just shows the activity screen with the icons on the home screen. I didn't use dialog but it looks like a dialog because layout is just set that way. So I just want to show the wallpaper whenever this activity is running. But it only shows the wallpaper only after the next event occurs such as switching to different activity. I already put that code on onCreate() and whenever I do setContentView()..... Is there way to do such thing or there is just no way?
For users of AppCompat, just use the following in your styles.xml, no need for code:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
After long search and trial and error. I've found the solution to what I wanted. It was just creating separate themes.xml file and just tweak the Theme.Dialog which is already defined in default android themes.xml. All I did was change the Animation part. Originally in android themes.xml the line looks like this.
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
but since modifying in android themes.xml doesn't take the effect. I just created my own themes.xml as I said above and just set parent as android:Theme.Dialog. And added a line like this.
<item name="android:windowAnimationStyle">#android:style/Animation</item>
Thanks for the help and I hope this solution helps others.
Use following code -
rl = (RelativeLayout)findViewById(R.id.someid);
//relative layout is my root node in main.xml (yours may be linearlayout)
WallpaperManager wm = WallpaperManager.getInstance(this);
Drawable d = wm.peekDrawable();
rl.setBackgroundDrawable(d);// You can also use rl.setBackgroundDrawable(getWallpaper);
I want to add a background image to my preference activity.
I tried by creating custom Theme:
<style name="MyPreference" parent="android:Theme.Light.NoTitleBar">
<item name="android:windowBackground">#drawable/preference_background</item>
</style>
and in the Manifest:
<activity android:name="SettingsActivity" android:theme="#style/MyPreference">
...
</activity>
But for some reason that caused to the PreferenceScreen to have a transparent background, like that:
Any idea how can i overcome that?