Android - Actionbar - android

i want to change the color of the actionBar, i was reading the appcelerator docs and reproduce the code with no results.
What am i doing wrong ?
tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.CustomActionBar"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" android:maxSdkVersion="23"/>
</manifest>
<manifest android:versionCode="3" android:versionName="1.0.1"/>
</android>
custom theme
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.CustomActionBar" parent="#style/Theme.AppCompat">
<item name="colorPrimary">#1565C0</item>
<item name="colorPrimaryDark">#0D47A1</item>
<item name="colorAccent">#FF80AB</item>
<item name="colorControlNormal">#757575</item>
<item name="colorControlActivated">#FF6E40</item>
<item name="colorControlHighlight">#FF4081</item>
<item name="colorSwitchThumbNormal">#BDBDBD</item>
<item name="android:colorButtonNormal">#BDBDBD</item>
<item name="android:colorEdgeEffect">#FF4081</item>
</style>
</resources>
Screenshot
Thanks in advance..
Titanium Appcelerator 4.5
SDK: 5.2.0 GA
Genymotion

Remove this line: <manifest android:versionCode="3" android:versionName="1.0.1"/> and put the android:versionCode and android:versionName into the first manifest tag.

Related

Xamarin Forms Android splash screen landscape orientation

I am trying to implement splash screen in portrait and landscape. Following link https://learn.microsoft.com/en-us/xamarin/android/user-interface/splash-screen
I added two separate files SplashBackground.xml and SplashBackgroundLandscape.xml with correct images. Added values-land folder with separate style.xml. Still the landscape image is not displayed on rotation. Am I missing anything?
Below is the style.xml for landscape. Portrait is same with drawable name #drawable/splash_portrait
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="android:windowBackground">#drawable/splash_landscape</item>
</style>
</resources>
Please see the updated screenshot with lower case names
Code for splash_landscape.xml. It has correct image name - splash_bg_landscape
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/colorPrimary" />
</item>
<item>
<bitmap android:src="#drawable/splash_bg_landscape" android:tileMode="disabled" android:gravity="center" />
</item>
Code for style.xml from values-land folder (for landscape mode)
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="android:windowBackground">#drawable/splash_landscape</item>
</style>
I feel everything is correct; however, when I deploy the app in landscape mode, it is not using the correct splash_bg_landscape image. App shows stretched portrait image. I am using Samsung device for testing.
I noticed that the item name "splash_landscape" is not same with "splashbackgroundlandscape",you may want to change that.
And below is my test sample solution structure you can take a look:
style(land):
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.companyname.myandroidtestapp">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<application android:allowBackup="true" android:theme="#style/MyTheme" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" >
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

TextInputLayout Crashing in Android Lollipop and Above

I am using TextInputLayout in one of my app layouts. My app is crashing on user's devices with Lollipop(5.1) version and above.
Below is the error
android.view.InflateException: Binary XML file line #34: Binary XML file line #2: Error inflating class android.support.design.widget.TextInputLayout arrow_drop_down
Caused by android.view.InflateException: Binary XML file line #34: Binary XML file line #2: Error inflating class android.support.design.widget.TextInputLayout arrow_drop_down
Caused by android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.TextInputLayout arrow_drop_down
Caused by java.lang.reflect.InvocationTargetException: arrow_drop_down
Caused by android.content.res.Resources$NotFoundException: File res/drawable-v21/design_password_eye.xml from drawable resource ID #0x7f0200b1 arrow_drop_down
Caused by android.content.res.Resources$NotFoundException: File res/drawable-v21/avd_show_password.xml from drawable resource ID #0x7f02005c arrow_drop_down
Caused by android.content.res.Resources$NotFoundException: File res/drawable-v21/avd_show_password_1.xml from drawable resource ID #0x7f0201bd arrow_drop_down
Caused by org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag x
I have tried all solutions at StackOverflow but they are not working. This include updating my libraries, using android:theme="#style/Theme.AppCompat" but my the app is still crashing.
TextInputLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="#style/Theme.AppCompat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:id="#+id/passwordInput"
app:hintTextAppearance="#style/UI.Text.HintText"
app:errorTextAppearance="#style/UI.Text.ErrorText"
android:textColorHint="#color/inputLabelColor"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#000000">
<EditText
android:textSize="18sp"
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textColorHint="#color/inputLabelColor"
android:textColor="#android:color/black"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:background="#drawable/apptheme_edit_text_holo_light"
/>
</android.support.design.widget.TextInputLayout>
build.gradle
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.all {
testLogging {
exceptionFormat = 'full'
}
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha6'
}
Kindly help me get rid of this bug. I feel like crying. :(
UPDATE
This files can be found in generated folder. e.g for design_password_eye.xml it can be found at /app/build/intermediates/exploded-aar/com.android.support/design/25.1.0/res/drawable-v21/design_password_eye.xml
I don't know why then it's declared missing and crashing my app
UPDATE 2
manifest(app)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.r.p">
<uses-sdk tools:overrideLibrary="com.base.ui.auth" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- To access Google+ APIs: -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- EXTERNAL_STORAGE permissions are optional for Android 6.0 onwards. -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application
android:name=".activities.AppApplication"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:theme">
// Activities here
</application>
</manifest>
Manifest for module auth(com.base.ui.auth)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.base.ui.auth">
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
//activities here
</application>
</manifest>
Styles
app module
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/md_blue_900</item>
<item name="colorAccent">#color/dialog_color</item>
<!--
This overrides the default dark or light dialog background color.
Note that if you use a dark color here, you should set md_dark_theme to
true so text and selectors look visible
-->
<item name="md_background_color">#android:color/transparent</item>
<!--To change the background of options menu-->
<item name="android:itemBackground">#color/app_actionBar</item>
<!--To change the text styling of options menu items</item>-->
<item name="android:itemTextAppearance">#style/itemStyle</item>
<item name="android:listPopupWindowStyle">#style/MyListPopupWindowStyle</item>
<item name="android:actionModeBackground">#color/app_actionBar</item>
<item name="android:actionModeCloseDrawable">#drawable/ic_action_close</item>
</style>
<style name="Toolbar" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/md_white_1000</item>
<!--<item name="android:background">#color/dark_blue</item>-->
</style>
<style name="Toolbar_Popup" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/md_black_1000</item>
<item name="android:background">#color/md_white_1000</item>
</style>
<style name="MyListPopupWindowStyle" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#color/app_actionBar</item>
<item name="android:textColor">#color/md_black_1000</item>
</style>
<style name="AppTheme.NoActionBar.PR" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#color/md_white_1000</item>
<item name="colorAccent">#color/md_blue_900</item>
</style>
<style name="AppTheme.NoActionBar.PC" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#color/md_white_1000</item>
<item name="colorAccent">#color/md_blue_900</item>
</style>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">#color/app_actionBar</item>
<item name="itemTextAppearance">#style/MyActionBar.MenuTextStyle</item>
</style
>
values-21
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:itemTextAppearance">#style/MyActionBar.MenuTextStyle</item>
<!--To change the background of options menu-->
<item name="android:itemBackground">#color/md_white_1000</item>
</style>
</resources>
styles for module auth
<style name="SplashTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">#color/app_background</item>
<item name="colorPrimary">#color/authui_colorPrimary</item>
<item name="colorPrimaryDark">#color/authui_colorPrimaryDark</item>
<item name="colorAccent">#color/authui_colorAccent</item>
<item name="colorButtonNormal">#color/authui_colorPrimary</item>
<item name="android:buttonStyle">#style/UI.Button</item>
<item name="android:editTextStyle">#style/UI.EditText</item>
</style>
<style name="UI.EditText">
<item name="android:textSize">16sp</item>
<item name="android:lineSpacingExtra">8sp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:colorActivatedHighlight">#color/authui_colorPrimary</item>
<item name="android:colorFocusedHighlight">#color/authui_colorPrimary</item>
</style>
Update your Gradle Plugin to 2.3.0 if you are on Android Studio 2.3:
classpath 'com.android.tools.build:gradle:2.3.0'
If you are on Android Studio 2.2 update to 2.2.3
classpath 'com.android.tools.build:gradle:2.2.3'
Also, update your libs references to 25.2.0
https://developer.android.com/studio/releases/gradle-plugin.html
It seems that TextInputLayout try to look up the resources like design_password_eye.xml only while using the default password-toggle Drawable.
So, we can avoid Resources$NotFoundException by setting app:passwordToggleDrawable="#null"
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleDrawable="#null"
app:errorEnabled="true">

AppCompat theme

I need your help for an issue occured about AppCompat theme. My MainActivity is derived from AppCompatActivity and the theme is declared in the Manifest but when I compile I get this error:
Java.Lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
This is the file containing the theme:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- your app branding color for the app bar -->
<item name="colorPrimary">#3F51B5</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">#303F9F</item>
<!-- theme UI controls like checkboxes, text fields and switchcompat button-->
<item name="colorAccent">#00FFFF</item>
</style>
And this is manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="test_vp.test_vp" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-feature android:name="android.hardware.wifi" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="#string/ApplicationName" android:theme="#style/MyTheme">
</application>
</manifest>
Do You know how can I solve it?
Thank You in advance
Change the first line of code you show:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
to
<style name="MyTheme" parent="#android:style/Theme.AppCompat.Light.NoActionBar">
Also, inside this style definition is where you put children definition to only there you define characteristics like color etc. It's a case of nested definition. Let me try to clear things:
First you define your main style which refers to your secondary style:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
Second, in this same xml you're working, below you define this child style, it is inside this where you choose colors etc. Pay attention with the name of this child theme - must be the same you referenced on parent:
<style name="MyTheme.ActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="colorPrimary">#3F51B5</item>
</style>
In some cases you will have to go deep inside this nesting, defining things by detailed steps. To resume: you can't change things directly, have to specify every detailed portion where you want to customize.
try:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.NoActionBar"></style>
It's in support lib, so ommit the "android:" part.

How can I find default colors for a given Android Theme?

I am using the AppCompat.NoActionBar theme. I'd like to know how to find the default colors for EditText lines and the Titles in DialogFragments. These defaults look like a teal color and I am also wondering if they are the same color or different. Is there an Android resource that lists out default colors by platform version?
Here is the themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar" >
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimary</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowDisablePreview">true</item>
</style>
<style name="FloatingLabel" parent="#android:style/TextAppearance" >
<item name="android:textColor">#color/colorFlLabelActivated</item>
</style>
...
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example..." >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme" >
<activity
android:name="com.example..."
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example..."
android:windowSoftInputMode="stateVisible|adjustResize"
/>
</activity>
</application>
colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#357EC7</color>
<color name="colorHint">#C0C0C0</color>
<color name="colorFlLabelActivated">#357EC7</color>
</resources>
goto to your android sdk and follow the path
\sdk\platforms\android-22\data\res\values\colors.xml
this contains the color code for all the items of the default theme
platform android-22 folder name can be different depending upon which platform tools you have installed for your sdk
As such there is no theme wise documentation but you might find following links useful and interesting.
For Theme Styling
Look at this documentation Styling the Action Bar
For Details on Themes and its Components
Please see this R.style
For Colour Details and Designing
See This Color palette ,UI color application ,Themes or you might want to have look at this Designing in Android

How could I disable all the over scroll effect in my app?

The blue shadow over scroll effect looks really ugly in our app.
Is there a way to disable all the over scroll effect? You know there are lots of ScrollViews and Lists in it... That would be a shame if I have to disable it in every widget that can
scroll...
thx~
You can do it simply
In layout.XML
Set
android:overScrollMode="never"
In scrollview
You can define a ScrollViewStyle and ListViewStyle in your Theme:
<style name="Theme.MyTheme" parent="android:Theme.Holo">
<item name="android:listViewStyle">#style/Widget.MyTheme.ListView</item>
<item name="android:scrollViewStyle">#style/Widget.MyTheme.ScrollView</item>
</style>
<style name="Widget.MyTheme.ListView" parent="android:Widget.ListView">
<item name="android:overScrollMode">never</item>
</style>
<style name="Widget.MyTheme.ScrollView" parent="android:Widget.ScrollView">
<item name="android:overScrollMode">never</item>
</style>
Then you have to define your Theme in you AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.citux.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:targetSdkVersion="16" android:minSdkVersion="8"/>
<application
android:hardwareAccelerated="true"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/Theme.MyTheme">
That's it, no more overscroll ;)
I have face same problem
try this code
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
You can disable all the over scroll effects by opening "res/values/styles.xml" file and adding the item line like bellow:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:overScrollMode">never</item>
</style>
Have you already used setOverScrollMode, with OVER_SCROLL_NEVER?

Categories

Resources