Trying to use holo theme in Android not working - java

I've been trying to set a holo theme in Android, but I haven't been able to get it to recognize it. Any ideas?
Posted is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:theme="#android:style/Theme.Holo">
<activity
android:name=".TestActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It gives me the red line under #android:style/Theme.Holo even if I change the minSdkVersion to 11. Any ideas?
Update:
I changed the line <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/> to <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/> and I am still getting the same error.
Update 2:
This ended up being that my target api was specified correctly in the manifest, but not in project properties. Weird, but now as is well.

Eclipse is giving you an error because SDK versions 7-10 won't know what Theme.Holo is. You need to provide separate styles for both platforms to ensure that the correct style will be found at runtime.
In your res/values/styles.xml file, create the following style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="#android:style/Theme.Black" />
</resources>
In your res/values-v11/styles.xml file, create the following style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="#android:style/Theme.Holo" />
</resources>
In your AndroidManifest.xml file, use the following line for your application's theme:
android:theme="#style/Theme.MyTheme"

you are trying to use the Holo theme for API Low than Android 4.0 that's why you get the red Line you can:
Use the HoloEverywhere project
Pick the necessary resources for Holo Theme you most want from the
ICS source and create your own custom theme/styles
https://github.com/android/platform_frameworks_base/tree/master/core/res
You ca also try to make use a custom theme for Android Api 7 to 10
and the holo theme for Api 11 and higher, see #Alex Lockwood's
answer.

The Holo theme needs to be updated in all of the style folders. Check under the values folder, values-sw600dp, values-sw720dp-land, values-v11 and values-v14. The theme on values-v14 overrides all other themes on the higher API's.

Related

Error parsing LocalFile: Please ensure that theandroid manifest is a valid XML document and try again

making an App for Android with flutter and VS code with JAVA as main activity in it everything works fine but sudden we come up with the error of invalid XML file of android manifest.
this is the code written in the manifest xml file
i have also try adding this android:usesCleartextTraffic="true" ,
but nothing works
XML
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examp.dp">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="wallyh"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:config Changes="orientation|keyboard Hidden|keyboard
|screenSize|smallest ScreenSize|locale|layout Direction|
font Scale|screen Layout|density|ui Mode"
android:hardware Accelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
`

How to change application icon for a libgdx android project

I'm trying to change the application icon for a libGDX Project, which I use to develop games. They give a sample ic_launcher.png file to use for setting the app icon, and I'm trying to change it to a different png file. I have specified everything for mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi, and also an anydpi, but in the AndroidManifest.xml, when I want to change the icon to #drawable/my_launcher, it says that it's an invalid symbol. I have even specified the same lengths and widths as the ic_launcher.png provided. Here is the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.zunkuftedu.zunkuftlife" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:isGame="true"
android:appCategory="game"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<activity
android:name="org.zunkuftedu.zunkuftlife.AndroidLauncher"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is a libGDX project, so it's different from normal Android Studio projects. Any help will be appreciated.
You shouldn't need to change any code. The android\res folder has folders with icons for different resolutions. You can simply overwrite the ic_launcher.png file in each of those folders with your own custom image (make sure you match the sizes of the existing images in each folder). That's how I've done it and it works great.

Android windowBackground attribute being ignored

Or kind of.
I've got an activity with a fragment container. Each Fragments layout has no background itself. I've already tried to set background to transparent - no effect.
Also I'm using FragNav library to handle fragment transactions.
The thing is - widnows background shows correctly in the editor xml preview.
Style:
<style name="AppTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#drawable/ng_window_background</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
Drawable "ng_windows_background" is just a shape with solid color. Colors HEX is #FDA23.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#color/colorAccent"/>
</shape>
XML preview example: The background color is orange.
Screenshot from device As you can see, the background color is gray.
What I've already tried:
Changing fragment's layout background (android:background) color. Yes, it works, but it causes overdraw effect, which I am trying to avoid by using android:windowBackground attribute.
Using android:colorBackground attribute, due to material components recommendations. No effect.
Changing app's theme programmatically and in manifest. No effect.
Changing Theme.MaterialComponents.NoActionBar to AppCompat. No effect + I can't use AppCompat due to some issues.
Changing background by getWindow().setBackgroundResource(); Neither in OnResume();
I guess it's an issue with MaterialComponents lib. I guess.
'can show any piece of code if necessary.
EDIT: manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packageName"
>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="AppClassPath"
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:roundIcon="#mipmap/logo_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=SplashScreenPath
android:theme="#style/AppTheme.Launcher">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=MainActivityPath />
</application>
</manifest>
EDIT #2:
Removed any functionality, leaving OnCreate() empty. No effect, so no problems with external libs.
help
Ok, the issue was with an external lib, called 'com.infideap.drawerbehavior:drawer-behavior:1.0.1'. Will try to figure out what was wrong and post a proper solution.Yeah.

Android "Hello World" Error

I'm new to Android development. I'm running Eclipse with the ADT plugin and installed all the necessary dependencies. I open up Eclipse, select 'New Android Applciation' and everything is set. When I run the app, I get an error message saying
/home/parallels/workspace/test/AndroidManifest.xml: 2: /home/parallels/workspace/test/AndroidManifest.xml: Syntax error: newline unexpected
So I look in Android Manifest and it's just the default, Eclipse generated code, right? What's the problem here?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.test.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Is there any empty space above your first line in your manifest? That has to be at the very top. Also have you compiled anything successfully thus far? Maybe something didn't get imported properly. I recommend android studio. It's just Googles modified version of eclipse that specializes in android development. It comes with everything you need all ready to go.

parentActivityName not found in package android, despite using API 16 and support libs [duplicate]

I'm trying to complete this tutorial from the Android Page http://developer.android.com/training/basics/firstapp/starting-activity.html But I Eclipse throws this error: "No resource identifier found for attribute 'parentActivityName' in package 'android'" I have included the android-support-library.
Here is the whole AndroidManifest.xml code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
android:parentActivityName appears first in Android 4.1 (API level 16). You need to have the latest 4.1 SDK to compile this.
To add to David Wasser's answer, if you use Eclipse and have the correct SDK library installed but still have this error, it means that while the correct library is installed Eclipse does not use it for this project.
To change that, go to your project's Properties (right-click on its name in the Package Explorer and it's the last but one option), select Android in the left hand column and you should have a list called Project Build Target. Then:
Select the appropriate target (Android 4.2.2 or Google APIs for Platform 4.2.2 in this instance)
Save your Manifest file (make a trivial edit if necessary)
Once it is saved Eclipse will process it and those errors should disappear as Eclipse finds the resource identifier in its new build target.
This error will also happen if you don't have the exact version of the SDK that the sample app uses as it's build target. Following the same steps as Julien describes above and choosing an SDK you have locally will fix it.
In IntelliJ IDEA, you need to change in Platform Settings->SDKs->Android something->Build target TO 4.1+.
If you don't see the option, you need an SDK version 4.1 or higher (API level 16+).

Categories

Resources