I created a project in Eclipse, worked a lot of in it and changed my IDE to Android-Studio. Now I need to change some things in style.xml and found out, that i did not was generated.
It possible to let it generate now?
PS: I added the library com.android.support:support-v13:22.1.1 to my project.
It could be under themes.xml
Here's a simple styles.xml template with my Activity extending AppCompatActivity
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
</style>
</resources>
It's under res->values->styles.xml
Related
I know this isn't a programming question, however this is a frustrating issue that I'm sure has an easy solution,
I have uploaded a screenshot for an error with my android studio emulator whereby any widget I drag and drop, doesn't show in the design view, but it does in the text view.
Any advice on this will be much appreciated.
Thanks.
Changing your theme in your styles.xml file to a Light Theme should do the trick.
You should change your Application Theme
Change your Application Theme by setting into the styles.xml and Manifest.xml file
Manifest.xml
<manifest ... >
<application android:theme="#style/Theme.AppCompat" >
</application>
</manifest>
Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Reference:-https://developer.android.com/guide/topics/ui/look-and-feel/themes
is there Application theme error then change into the style.xml and Manifest.xml file.
otherwise clean project or Rebuild project your project.
Go To Build -> Rebuild Project OR Build -> clean Project.
is there any error then show on logcat
Check if your SDK build tools is up-to-date. If not, try updating it first.
When I create new project for lower android 2.2 label API8 in eclipse there are some error and i can't fixed them. appcompat_v7 inside some problem no found values-v17 - values-v21 and there are also some error my project folder.
After creating ... ...
But when I create project for higher android 4.0 label API(14) there are no error.
After creating ... ...
There are any way to solve this problems.
In 4.0 they use android: prefix for styles but in 2.2 they does not recognise
In 4.0
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="#android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
in 2.2
<style name="WindowTitle">
<item name="singleLine">true</item>
<item name="textAppearance">#style/TextAppearance.WindowTitle</item>
<item name="shadowColor">#BB000000</item>
<item name="shadowRadius">2.75</item>
</style>
like wise things changed. So refer the android developer.android.com
Or you can use separate stylesheet from 2.2 . And also without seen the style.xml we cant say that this is the exact problem.
You need to modify your style.xml to ensure API's are supported. Please check this SO post Android AppCompat requires API level 11
This should help you solve the problem you face.
I have an Android project using another one as library. So far I've been working on Eclipse with Maven, now I want to migrate to Android Studio and Gradle.
The problem is that I use to do the following in Eclipse:
Library project:
<style name="some_theme">
<item name="android:textColor">#00FF00</item>
</style>
And then in my main project:
<style name="some_theme">
<item name="android:typeface">monospace</item>
</style>
So, if the theme name is the same in Eclipse I get whats been defined in both themes, but in Android studio I only get what's on the main project
Has someone encounter this type of issue before? Does someone know a way to solve it? (Other than just copy all what's on the library project...)
Regards
Jose
That shouldn't work. When you define two styles with the same name in two different places, you should run into a naming conflict. There is no documented style resource merging feature. The fact that it works in Eclipse with ADT is probably accidental.
The correct way to do this is to define one style in your library, and inherit from that style in your application.
For example, in your library project:
<style name="SomeThemeBase">
<item name="android:textColor">#00FF00</item>
</style>
Then in your application project:
<style name="AppTheme" parent="SomeThemeBase">
<item name="android:typeface">monospace</item>
</style>
This way you do not create a naming conflict, but your app's theme still inherits the properties you defined on the base theme.
I am trying to customize the material design theme as suggested in this link :
android dev
but when I add the following code to my v21/styles file Intellij says that it cannot resolve these symbols.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">#color/material_blue_500</item>
<item name="colorPrimaryDark">#color/material_blue_700</item>
<item name="colorAccent">#color/material_green_A200</item>
</style>
</resources>
I looked around to see if there are any particular settings that need to be done on the color side but nothing came up. I am using API 21 with support lib v7 on gradle.
#color/material_blue_500 and others are not the resources in android library.
You must define the color resources in res/values/colors.xml by yourself.
such as <color name="material_blue_500">#5677fc</color>.
And then you can use it as <item name="colorPrimary">#color/material_blue_500</item>.
Android docs are very vague on this, leading to confusion. To get the predefined colors copy color_material.xml to your local res/values dir. That file is a preserved version as it was during Android-L. The offical version which sits in your local directory:
...sdk/platforms/android-21/data/res/values/colors_material.xml
has been trimmed down to remove those color definitions.
I am trying to run an simple android project from a tutorial, However I am receiving the popular "R cannot be resolved to a variable" error. I have checked my gen folder and the R.id file is not there. This is the list of things I have tried so far:
have done a clean build several billion times.
fixed the project properties
There are no errors in my .xml files and they do not contain uppercase letters etc.
The package name in the source and manifest are exactly the same.
Have installed the latest SDK updates + restarted eclipse.
have deleted the gen file and done another clean build.
There is only an error in the source files, according to eclipse.
Here is a themes.xml file that may be causing a problem:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">#+color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>
<!-- ActionBar tabs text styles -->
<style name="MyActionBarTabText"
parent="#android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
</style>
</resources>
Apologies in advance if this sounds familiar, but I have tried everything I have seen from previous posts.
Happy to provide more details if needed. Thanks in advance.
Theme.Holo and Widget.Holo.ActionBar requires API Level 11
TextAppearance.Holo.Widget.ActionBar.Title and Widget.Holo.ActionBar.TabText requires API Level 13
Check your android:minSdkVersion. If it is less than 13 than you can't build your project(or you have to duplicate your styles for different API Levels, using different api level folders under res). eclipse shows this kind of errors.
And also your Android Project Build Target must be at least API Level 13.