Setting the theme in an android application - android

I've gone through quite a bit and I'm still at a loss for what I need to do:
http://developer.android.com/design/style/themes.html
http://developer.android.com/guide/topics/ui/themes.html
I have the view set to use the "Dialog" theme in my IDE (IntelliJ IDEA 14.1.2) and the application looks like this in the insepctor:
However looks completely different on my phone (Much larger resolution, but that's not the point).
What am I doing wrong and how can I get this effect?

i use this in one of my activities and it is ok:
<activity
android:name="eddine.charef.mechalikh.swipedemo.mapDialog"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:theme="#android:style/Theme.Dialog" ><!--add this-->
</activity>
maybe your android version doesn't support that.

Add to the Android Manifest
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>

Related

Odd PreferenceActivity Theme on Samsung Devices

I'm seeing a very odd theme issue in my PreferenceActivity only on Samsung devices (as far as I'm aware).
-----EDIT (Removed irrelevant code)-----------
The following is an unthemed preference activity:
<activity android:name=".FullSettingsActivity"/>
Setting theme for the FullSettingsActivity:
<activity android:name=".FullSettingsActivity"
android:theme="#style/Theme.AppCompat.NoActionBar" />
yields this:
So clearly the default theme for Samsung devices is rather odd. Is there any reason a PreferenceActivity would end up unreadable like that only on Samsung devices?
Try changing your theme from #style/Theme.AppCompat.NoActionBar to something else like android:Theme.Holo.Light.NoActionBar and see the difference.
Also make sure you add that GalleryTheme in your AppManifest.xml in your application tag like android:theme="#style/GalleryTheme"
Hope that helps.

iOS 7 blur in Android

I'm working on a new Android app designed in really flat style. I want to have a DialogAlert that shows up on a blurred background. Effect similiar to the control center on this photo (don't write about NDA, this photo is available on Apple's website):
Is it possible? If so, the most important question: how?
M.
Yes this is possible, You have to use something called renderscript.
so what you need is bitmap from the view this can be done using the following code.
View v // target view to be blurred
v.setDrawingCacheEnabled(true);
Bitmap screenshot = Bitmap.createBitmap(v.getDrawingCache());
Now use the renderscript to get the blurred bitmap shown here
http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android/ and draw it to your view.
Yes it is possible. Instead of creating a Dialog, Create and Activity and In your Manifest add android:theme="#android:style/Theme.Dialog" to your activity like below:
<activity
android:name=".Activity"
android:label="#string/title_activity"
android:theme="#android:style/Theme.Dialog">
<intent-filter>
<action android:name="example.package" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
It can be done, but there's no quick and easy way to do it. Check our the BlurMask filter in the Android developer documentation or Android, how to blur/glass/frost current activity for some suggested steps.
Create the blurred bitmap in Photoshop and set it as the Activity/Dialog's background drawable.

android:#Theme.Translucent Locks orientation to Portrait?

I've created a new style to set the background as transparent, but for some reason ever since the app doesn't change layout to landscape when device is rotated.
Should I specify something in the new style ?
Here is it's code :
< style name="Transparent" parent="android:#Theme.Translucent">
< item name="android:windowBackground">#color/background</item>
</style>
While you are not specify android:screenOrientation for activty, android uses
"unspecified" default value, which means that the system chooses the orientation.
In a case you are using style with <item name="android:windowIsTranslucent">true</item>, system selects an orientation based on the orientation of underlying activity in stack. So it's hard to get your application in landscape mode, because most of launchers fixed to portrait.
Just set android:screenOrientation="sensor" for all Translucent activities to force it choose orientation independently:
<activity
android:name=".SomeActivity"
android:screenOrientation="sensor"
...>
...
</activity>
I actually kinda solved it apparently the orientation is according to the background app in case of transparent background, since i kept testing when the Launcher in the back, i always got portrait only.
just right in manifest
<activity
android:name=".Ippin_NewActivity"
android:configChanges="keyboardHidden|orientation"
android:label="#string/app_name" >
</activity>

Feature Custom Title: Cannot combine custom titles on API 11 and above

I have a project in which i setted:
minSdkversion setted to 10
MainActivity is a TabActivity
Code in onCreate method is this:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
...
With previous settings, all works well! But, if i set minSdkVersion to 11 or above, this exception occurs:
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
I don't understand why happens this just changing minSdkVersion.
I red a lot about this problem on this site. I tried setting:
Theme.NoTitleBar in main layout and after in Manifest file too
I put those 3 lines in all possible positions
If i comment first line a NullPointerException occurs when i call something on my TextView reference of my CustomTitle layout
I tried setting, in theme.xml file declaration, "windowNoTitle" = true
Since i'm using functions available from API 11 only, i want to set minSdk to 11 before loading App on Store. How can i do ?? I need Help
Edit: With minSdkVersion = 10 and Theme.NoTitleBar in Manifest, same error occurs. Removing it, all works as before.
Can anyone provide a working code (manifest and activity code) for setting a custom title when API is 11 or above ? Thx much
Fixed by my self. I don't know why, but simply adding in manifest file "theme" property for each activity's declaration, all works:
From this:
<activity
android:name=".CheckActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
</activity>
To this:
<activity
android:name=".CheckActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="#android:style/Theme" >
</activity>
#kinghomer I have tried CUSTOM_TITLE its on 2.2 (API 8) actually. Let me try on API 11 and get back to you!
Before that, you need not make Theme.NoTitleBar anywhere, can be controlled in .java file directly. Give me some time, will be back!
res/values-v11 defalut use this code :
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
change "android:Theme.Holo.Light" to "#android:style/Theme" will be ok!
tips: if your project no have "res/values-v11", then check your project referenced "lib project" 。
Other than the accepted answer ,there is another way to solve this :
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme" >
assign a theme attribution to application in the xml-based mainifest,that should work for all activities.
This problem occurs when you try to add a custom title bar along with extending your activity by ActionBarActivity or AppcomActivity. These two activity classes already have title bar defined.
So, when you try to add your own custom title bar a conflict arises, which title bar to use - your custom one or the one provided by activity extended.
To solve this issue, just extend your activity by Activity which does not have any predefined title bars, so yours will be accepted without any conflict.
public void MyActivy extends Activity
{
// your code
}
I just added android:theme="#android:style/Theme" in activity in AndroidManifest.xml file and it worked super fine.
<activity
android:name=".MainActivity"
android:theme="#android:style/Theme" >
</activity>
Hope this works for you as well.
In your AndroidManifest file, use this snippet instead of yours.
From this:
android:theme="#style/AppTheme">
to this:
android:theme="#style/custom_title">

The theme in manifest.xml

I change
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
to
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
But why it can not change orientation?
If use android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen", it can change orientation.
But if change to another one, it can't.
I try it in Android 2.3.4.
But in Android 4.0.2, it works success on change orientation.
Why and how to avoid it?
Add
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
to each activity you need.

Categories

Resources