Odd PreferenceActivity Theme on Samsung Devices - android

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.

Related

Force app widget's light theme on OnePlus phone with Android 12

I have a problem with forcing a light theme of home screen app widget on OnePlus 9 phone with Android 12 (using the OnePlus' launcher). My widget's theme inherits from Theme.MaterialComponents.Light and is light on Android 11 and below, even when the phone is in the dark mode.
Problem is on Android 12, where the widget's background is always very dark, when the phone is in the dark mode. When I set pure white background, it ends-up almost black. Pure red is dark red, pure green is dark green, etc. Looks like something in the system is tinting the background colors. The same is happening with Theme.Material3.Light and #android:style/Theme.DeviceDefault themes.
Everything is good on pure Android in an emulator, so this looks like a OnePlus issue. Any ideas what can be wrong and how to fix this?
Goto to your themes file and place the following line in the style you are using for your app.
<item name="android:forceDarkAllowed">false</item>
You can create a Application Class which extends Application() and place the following code in OnCreate() like this
class YourApplicationClass : Application(){
override fun onCreate() {
super.onCreate()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
}
Then in your manifest file add this application class like this
<application
android:name=".base.YourApplicationClass"
...
/>

Setting the theme in an android application

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"/>

How do I change the theme of a SettingsActivity in Android?

TL;DR: How am I supposed to change the background of a SettingsActivity to be white or off-white to match Holo.Light? Changing the theme of the app changes the text but keeps the background as black.
I recently changed the theme of my application from default (Holo) to Holo.Light. Everything seemed to work perfectly until I opened my SettingsActivity and was greeted by this:
As you can see, all of the test is black on a black background.
This is the original:
I am trying to make the settingsActivity have a white background.
I have added the following to my Manifest:
<application
...
android:theme="#android:style/Theme.Holo.Light" >
...
<activity
android:name="edu.purdue.SafeWalk.settings.SettingsActivity"
...
android:theme="#android:style/Theme.Holo" >
</activity>
However even the redundant theme setting does not help.
Obviously it is changing the theme of the text, but not the background which leads me to believe that I have manually overridden the background color. However I have not defined a layout for this SettingsActivity and I see no XML or Java that sets the background.
I can post whatever other relevant code here, but the source is public here.
How am I supposed to change the background of a SettingsActivity to be white or off-white to match Holo.Light?
You'll want to remove
view.setBackgroundColor(getResources().getColor(android.R.color.black));
from line 101 of SettingsFragment.java, cheers!

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">

Categories

Resources