Android autocomplete background yellow color on EditText - android

I have been trying different solutions without success to remove the yellow paint of autocomplete on textfield.
I tried 3 different ways to use:
<item name="android:autofilledHighlight">#android:color/transparent</item>
tried in version v26, with tools:targetApi="o" and tools:ignore="NewApi". Also tried the solution on developers.android to create a transparent shape.
This is my style:
<style name="editText" parent="Theme.AppCompat">
<item name="android:autofilledHighlight" tools:ignore="NewApi">#color/transparent</item>
<item name="colorControlNormal">#color/lightGray</item>
<item name="colorPrimary">#color/darkGray</item>
<item name="colorPrimaryDark">#color/lightGray2</item>
<item name="colorAccent">#color/mainOrange</item>
</style>
this is my EditText:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/login_emailinputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/editText"
android:layout_marginStart="55dp"
android:layout_marginLeft="55dp"
android:layout_marginTop="55dp"
android:layout_marginEnd="55dp"
android:layout_marginRight="55dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView5">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:theme="#style/editText"
android:textCursorDrawable="#drawable/cursor"
app:backgroundTint="#color/mainOrange" />
</com.google.android.material.textfield.TextInputLayout>
This is my gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.android.volley:volley:1.1.1'
}
Everything works except the autocomplete yellow paint. Any help will be much appreciated.

Related

android.support.v7.widget.CardView could not be found Android Studio [duplicate]

This question already has answers here:
How to add cardview in layout xml in AndroidX
(10 answers)
Closed 3 years ago.
I am following this tutorial for Android app :
https://www.youtube.com/watch?v=wW-AAXOy4u4
I added a list that may contain some items; For each item, I want it to be a Card. Created the card, imported dependencies in build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup:android-times-square:1.6.5#aar'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
}
as suggested here:
android.support.v7.widget.CardView could not be found (Android Studio 1.1 Preview)
Nevertheless, I still get the "android.support.v7.widget.CardView could not be found" error.
The error that I get:
The following classes could not be found:
- android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create
Class)
Tip: Try to build the project. Tip: Try to refresh the layout.
Here is my main_activity_single_item code:
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#color/colorAccent"
android:elevation="4dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="80dp"
android:layout_height="105dp"
android:id="#+id/ivMain"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvMain"
android:textStyle="bold"
android:layout_toRightOf="#+id/ivMain"
android:layout_marginLeft="6dp"
android:layout_toEndOf="#+id/ivMain"
android:text="Timetable"
android:textSize="24sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvDescription"
android:layout_below="#+id/tvMain"
android:layout_toRightOf="#+id/ivMain"
android:layout_marginLeft="6dp"
android:text="Description"
android:textSize="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvClick"
android:textSize="12dp"
android:text="click here"
android:layout_below="#+id/tvDescription"
android:layout_alignBottom="#+id/ivMain"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
What I already tried:
changed in
res->value->styles
from <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
to <style name="AppTheme" parent="Base.Theme.AppCompat.Light.NoActionBar">
(error)
File .. Invalidate caches / restart
Build project
I work on Android Studio, my API version is 22
Can you please, share your insights on this issue ?
Please let me know if you need some extra information.
Thank you very much.
Either use
androidx.cardview.widget.CardView
or
com.google.android.material.card.MaterialCardView
instead of
android.support.v7.widget.CardView

Group visibility with android constraint layout 1.1.3 not working

I'm just trying to use the group view with the android constraint layout to set the visibility of several views more easily. Problem is even though I change the visibility of a group to gone or invisible it does not do anything.
I'v already tried the steps of Pavan's response in this thread: toggle visibility of chain group in constraint layout.
But it didn't change anything for me. (I assume it's because I'm not using the beta version)
Here is my dependencies app gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is an extract of my XML file with the group
<Button
android:text="#string/action_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button_update"
android:layout_marginBottom="32dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent" android:textSize="18sp"/>
<android.support.constraint.Group android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/group"
android:visibility="gone"
app:constraint_referenced_ids="button_update"/>
You are importing the Group widget from a wrong package.
Change
<android.support.constraint.Group
To
<androidx.constraintlayout.widget.Group
Updated Version
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
..............................................
>
<Button
android:id="#+id/button_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="32dp"
android:text="#string/action_update"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="#+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="button_update" />
</androidx.constraintlayout.widget.ConstraintLayout>
The thing is I didn't notice that when I created my android studio project, i didn't check the box "Use androidx artifacts" which automatically makes your project use the new androidx library. Androidx tends to replace the support library (See more details here: https://developer.android.com/jetpack/androidx)
So basically, I followed the steps given here to convert my project to androidx and now everything is working perfectly.
Thank for your time #theapache64, now your code is working.

Problem with design of Text Input Layout?

The label hint color doesnt works, i created the color Bluesky, but only works with the linear box but the label dont.
<android.support.design.widget.TextInputLayout
android:id="#+id/til1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="0dp"
android:layout_weight=".8"
android:textColorHint="#color/BlueSky"
app:boxStrokeColor="#color/BlueSky"
app:counterEnabled="true"
app:counterMaxLength="7"
app:errorEnabled="true"
app:hintEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/tid1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:elevation="7dp"
android:hint="Test"
android:inputType="number|numberDecimal"
android:maxLength="7"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
mi build gradle:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-
layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'
}
I use the version 3.4 of android studio.
the label color on the input layout is the colorAccent of your project. If you change this color to BlueSky you'll see what you want.
<color name="colorAccent">#D81B60</color>
But maybe there's another way to style this widget without changing the colorAccent (because this color is used by other widgets too).

Not able to position com.facebook.login.widget.LoginButton at the center

Have added a Google Sign in and Facebook button as shown below
<com.google.android.gms.common.SignInButton
android:id="#+id/loginWithGPlusBtn"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.1"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toTopOf="#+id/loginWithFacebookBtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/raylImage"
app:srcCompat="#mipmap/ic_gp_login" />
<com.facebook.login.widget.LoginButton
android:id="#+id/loginWithFacebookBtn"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.1"
app:layout_constraintStart_toStartOf="parent" />
Now, although the G+ button shows up properly, with the text in the middle of the box, I have no such luck with FB. I can manually add a fixed padding like this:
android:paddingTop="10dp"
but this will take away the flexibility of positioning for different sized screens. Tried different settings, but no luck yet. Any ideas ?
Gradle dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:percent:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.facebook.android:facebook-core:[4,5)'
implementation 'com.facebook.android:facebook-login:[4,5)'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

FAB: Drawable already belongs to another owner

I added two floating action buttons on a fragment but I always get following error:
Invalid drawable added to LayerDrawable! Drawable already belongs to another owner but does not expose a constant state
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_weight="1"
android:id="#+id/scrollView"
android:layout_marginRight="30dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/layout_main_account">
<TextView
android:text="Name"
android:textStyle="bold"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_activity_main_account_name_label"/>
<EditText
android:enabled="false"
android:inputType="none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/et_activity_main_account_name_label_value"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="0dp"/>
<android.support.design.widget.FloatingActionButton
android:backgroundTint="#000"
android:layout_marginBottom="5dp"
android:layout_marginRight="10dp"
app:layout_anchorGravity="bottom"
android:layout_width="wrap_content"
android:layout_gravity="bottom|end"
android:layout_height="wrap_content"
android:src="#drawable/ic_edit_account"
android:id="#+id/fbtn_activity_main_account_edit_account"/>
<android.support.design.widget.FloatingActionButton
android:backgroundTint="#000"
android:layout_marginBottom="5dp"
app:layout_anchorGravity="bottom"
android:layout_width="wrap_content"
android:layout_gravity="bottom|end"
android:layout_height="wrap_content"
android:src="#drawable/ic_home_account"
android:id="#+id/fbtn_activity_main_account_manage_addresses"
app:layout_anchor="#id/fbtn_activity_main_account_edit_account"/>
</LinearLayout>
</RelativeLayout>
drawable -> ic_edit_account.xml
<vector android:height="24dp" android:viewportHeight="60.017"
android:viewportWidth="60.017" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M59.144,3.731l-2.85,-2.851c-1.164,-1.161 -3.057,-1.162 -4.221,0.001l-3.126,3.126H0v56h56V11.097l0.305,-0.305l0,0l2.839,-2.839C60.308,6.789 60.308,4.895 59.144,3.731zM20.047,36.759l3.22,3.22l-4.428,1.208L20.047,36.759zM52.062,12.206L47.82,7.964l1.414,-1.414l4.243,4.242L52.062,12.206zM50.648,13.62L25.192,39.076l-4.242,-4.242L46.406,9.378L50.648,13.62zM54,13.097v44.91H2v-52h44.947L18.829,34.127l-0.188,0.188l-2.121,7.779l-1.226,1.226c-0.391,0.391 -0.391,1.023 0,1.414c0.195,0.195 0.451,0.293 0.707,0.293s0.512,-0.098 0.707,-0.293l1.226,-1.226l7.779,-2.123l26.351,-26.35h0l0.447,-0.447L54,13.097zM57.73,6.539l-2.839,2.839l-4.243,-4.243l2.839,-2.839c0.384,-0.384 1.009,-0.383 1.393,0l2.85,2.85C58.114,5.529 58.114,6.155 57.73,6.539z"/>
</vector>
drawable -> ic_home_account.xml
<vector android:height="24dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M506.555,208.064L263.859,30.367c-4.68,-3.426 -11.038,-3.426 -15.716,0L5.445,208.064c-5.928,4.341 -7.216,12.665 -2.875,18.593s12.666,7.214 18.593,2.875L256,57.588l234.837,171.943c2.368,1.735 5.12,2.57 7.848,2.57c4.096,0 8.138,-1.885 10.744,-5.445C513.771,220.729 512.483,212.405 506.555,208.064z"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M442.246,232.543c-7.346,0 -13.303,5.956 -13.303,13.303v211.749H322.521V342.009c0,-36.68 -29.842,-66.52 -66.52,-66.52s-66.52,29.842 -66.52,66.52v115.587H83.058V245.847c0,-7.347 -5.957,-13.303 -13.303,-13.303s-13.303,5.956 -13.303,13.303v225.053c0,7.347 5.957,13.303 13.303,13.303h133.029c6.996,0 12.721,-5.405 13.251,-12.267c0.032,-0.311 0.052,-0.651 0.052,-1.036v-128.89c0,-22.009 17.905,-39.914 39.914,-39.914s39.914,17.906 39.914,39.914v128.89c0,0.383 0.02,0.717 0.052,1.024c0.524,6.867 6.251,12.279 13.251,12.279h133.029c7.347,0 13.303,-5.956 13.303,-13.303V245.847C455.549,238.499 449.593,232.543 442.246,232.543z"/>
</vector>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.atta"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// retrofit, gson
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.basgeekball:awesome-validation:4.1'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
}
Note: Each drawable is used only once.
The following thread does not solve my problem:
Drawable already belongs to another owner but does not expose a constant state
Problem found: The following attribute is causing the exception:
android:backgroundTint="#000"
If I don't use it, there is a pink background on the FAB :(
Fixed:
Added xmlns:app="http://schemas.android.com/apk/res-auto" in top layout
Used app:backgroundTint="#color/colorFABTint" instead of android:backgroundTint="#000"
Added following line in colors.xml
<color name="colorFABTint">#000000</color>
Resultant xml:
<RelativeLayout
android:layout_margin="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.FloatingActionButton
android:layout_marginBottom="5dp"
app:layout_anchorGravity="bottom"
android:layout_width="wrap_content"
android:layout_gravity="bottom|end"
android:layout_height="wrap_content"
android:src="#drawable/ic_home_account"
app:backgroundTint="#color/colorFABTint"
android:id="#+id/fbtn_activity_main_account_manage_addresses"
app:layout_anchor="#id/fbtn_activity_main_account_edit_account"/>
Drawable has a state, and if you assign it to more than one Floating Action Button, then there will be a problem keeping track of the Drawable's state.
Maybe there is better solutions but one solution may be to set fab icons in onCreate instead of layout you can remove fab src from layout and use this:
fab.setImageResource(getResources().getDrawable(R.drawable.ic_edit_account).mutate());
or maybe this:
fab.setImageResource(getResources().getDrawable(R.drawable.ic_edit_account).getConstantState().newDrawable());

Categories

Resources