I am working on an Android application using Android Studio and I am using TextInputEditTexts to input registration fields. This is the code (Activity.xml file)
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/partitaIvaText"
android:layout_width="118dp"
android:layout_height="55dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputEditTextLayoutPartitaIva"
android:layout_width="match_parent"
android:layout_height="55dp"
android:ems="10"
android:hint="@string/PartitaIVARequired"
android:inputType="number"
android:singleLine="true"
style="@style/MyTextInputEditTextStyle"
/>
</com.google.android.material.textfield.TextInputLayout>
here is the style.xml file:
<style name="MyTextInputEditTextStyle" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/custom_input</item>
<item name="android:textColor">@color/grigio_scuro</item>
<item name="android:textColorHint">@color/grigio_chiaro</item>
<item name="android:textCursorDrawable">@drawable/cursor_color</item>
<item name="android:fontFamily">@font/roboto</item>
</style>
and here are the 2 drawable files
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/bianco"/>
<corners android:radius="10dp"/>
<stroke android:color="@color/marrone_primario" android:width="1dp" />
</shape>
</item>
<item android:state_enabled="true">
<shape android:shape="rectangle">
<solid android:color="@color/bianco"/>
<corners android:radius="10dp"/>
<stroke android:color="@color/marrone_secondario" android:width="1dp"/>
</shape>
</item>
</selector>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="1dp" />
<solid android:color="@color/marrone_primario" />
</shape>
in the Android Studio editor, I see this Android Studio Editor: this is how is shown on some phones
But on my phone (and many others) i see this Screenshot from my phone
On some phones, it appears correctly, and I am not sure how to fix the issue (I think it might have something to do with my phone's theme, and I would like to make sure it is always displayed correctly).
I tried moving all the graphical modifications to style.xml hoping it would make a difference, but I still can't figure out how to make it work correctly.
In the end, I was able to find a solution thanks to the post: How to use only light mode in aplication? Android Studio
The problem was due to the fact that the dark theme for our application had not been implemented correctly, so I decided to directly force the light theme using this line of code before the method setContentView in all my Activities:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);