weird bug with TextLayout UI errors

Eduardo Gomez 3,416 Reputation points
2022-08-19T03:22:44.29+00:00

I have a Xamarin.Android app, and for some weird reason my edit tet are getting squached

look at this

Register Activity Layout

232677-image.png

Main Layout // This one is fine

232579-image.png

What I don't understand, is that both layouts have the same code

MainActivity

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:app="http://schemas.android.com/apk/res-auto"  
    xmlns:tools="http://schemas.android.com/tools"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    android:orientation="vertical"  
    android:background="#ff4baae1">  
  
  
    <com.google.android.material.textfield.TextInputLayout  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_margin="10dp">  
  
        <EditText  
            android:inputType="textEmailAddress"  
            android:hint="Email"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"  
            android:id="@+id/Main_txtEmail"  
            tools:ignore="HardcodedText" />  
  
    </com.google.android.material.textfield.TextInputLayout>  
  
  
    <com.google.android.material.textfield.TextInputLayout  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_margin="10dp"  
        tools:ignore="UselessParent">  
  
        <EditText  
            android:inputType="textPassword"  
            android:hint="Password"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"  
            android:id="@+id/Main_txtPassword"  
            tools:ignore="HardcodedText" />  
  
    </com.google.android.material.textfield.TextInputLayout>  
  
    <Button  
        android:backgroundTint="#4B0082"  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_marginLeft="10dp"  
        android:id="@+id/Main_SignInBton"  
        android:layout_marginRight="10dp"  
        android:text="Sign in"  
        tools:ignore="HardcodedText" />  
  
    <TextView  
        android:layout_width="wrap_content"  
        android:textColor="#228"  
        android:id="@+id/Main_RegiterTV"  
        android:layout_height="wrap_content"  
        android:layout_gravity="center_horizontal"  
        android:text="Do do not have an account?"  
        android:layout_marginTop="10dp"  
        android:layout_marginStart="10dp"  
        android:textAlignment="center"  
        tools:ignore="HardcodedText"  
        android:clickable="true" />  
  
</LinearLayout>  

RegisterAActivity

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools"  
    android:orientation="vertical"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    android:background="#ff4baae1">  
  
    <com.google.android.material.textfield.TextInputLayout  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_margin="10dp"  
        >  
  
        <EditText  
            android:inputType="textEmailAddress"  
            android:hint="Email"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"  
            android:id="@+id/Register_txtEmail"  
            tools:ignore="HardcodedText" />  
  
    </com.google.android.material.textfield.TextInputLayout>  
  
  
    <com.google.android.material.textfield.TextInputLayout  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_margin="10dp">  
  
        <EditText  
            android:inputType="textPassword"  
            android:hint="Password"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"  
            android:id="@+id/Register_txtPassword"  
            tools:ignore="HardcodedText"   
            />  
  
    </com.google.android.material.textfield.TextInputLayout>  
  
    <com.google.android.material.textfield.TextInputLayout  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_margin="10dp">  
  
        <EditText  
            android:inputType="textPassword"  
            android:hint="Confirm Password"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"  
            android:id="@+id/Register_txtConfirm"  
            tools:ignore="HardcodedText"   
             />  
  
    </com.google.android.material.textfield.TextInputLayout>  
  
    <Button  
        android:backgroundTint="#4B0082"  
        android:layout_width="match_parent"  
        android:layout_height="wrap_content"  
        android:layout_marginLeft="10dp"  
        android:id="@+id/Register_registerBton"  
        android:layout_marginRight="10dp"  
        android:text="register"  
        tools:ignore="HardcodedText"   
         />  
  
  
</LinearLayout>  

I try it on my phone, and I got the same result. Also, the color of the text on the bottom is different, but why

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,121 Reputation points Microsoft Vendor
    2022-08-23T05:22:49.157+00:00

    Hello,

    Your issue is caused by that Activity and AppCompatActivity used different themes, you could change the inherited class from Activity to AppCompatActivity.

    Your second issue is caused by the AppTheme style, please open the YourProjectName\Resources\values\styles.xml file, then modify <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar"> to <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful