EditText not working as expected. Maybe a nesting problem? - java

So, I have this activity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ListView
android:id="#android:id/setting_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:layout_weight="1"
/>
<!-- fragment container -->
<ScrollView
android:id="#+id/scrollfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/fragment_container"
/>
</ScrollView>
</LinearLayout>
In the fragment_container FrameLayout, there's going to be some settings for my app.
I have edit nickname and edit password fragments, each with its EditTexts in them.
Problem is, as I try to type anything in any of these EditTexts (email, old password, new password, confirm password), I get no feedback. Nothing. Just as if I was tapping on a TextView or anything you can't interact with. It's obviously not what I want, since I need to be able to change those settings.
I really have no idea of what to do, partially because everything I tried to google resulted in some guides on how to deactivate my EditTexts, which is the exact opposite of what I have to do. Yes, I tried doing the opposite those guides suggested.
Didn't work.
Anybody can help me? I can show you every line of code you need me to.
EDIT:
my change password fragment:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".FragmentCambioPassword">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/window_background"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/activity_horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
tools:ignore="MissingConstraints">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:visibility="gone"
tools:ignore="MissingConstraints" />
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayoutOldPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.100000024">
<EditText
android:id="#+id/oldPassword"
android:layout_width="match_parent"
android:layout_height="56dp"
android:focusableInTouchMode="true"
android:hint="#string/old_password"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:clickable="true"
android:textColor="#android:color/black" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayoutPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.100000024">
<EditText
android:id="#+id/newPassword"
android:layout_width="match_parent"
android:layout_height="56dp"
android:focusableInTouchMode="true"
android:hint="#string/new_password"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/black" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayoutConfPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.100000024">
<EditText
android:id="#+id/confPassword"
android:layout_width="match_parent"
android:layout_height="56dp"
android:focusableInTouchMode="true"
android:hint="#string/confirm_password"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/black" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/changePsw"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#color/colorPrimary"
android:text="#string/cambia"
android:textColor="#android:color/white"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>```
all other fragments are done in a similar fashion. Please ask if you need more.

Related

Hint and User Input overlaying in a TextView

I've never seen this happen before, and have no idea what is causing it, my first choice was to hide hint with a piece of java code within the fragment, but I failed so hard at in that now I just wanna find a XML solution.
This is happening to every field, and I can't find anything wrong with the layout here, any insights?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_nome_contato"
android:inputType="textPersonName"
android:lines="1"
android:padding="10dp"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_email_contato"
android:inputType="textEmailAddress"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_empresa_contato"
android:inputType="text"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_tel_empresa_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_matricula"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Digite sua matricula (Opcional)"
android:inputType="number"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<sinapse.com.br.estilo.component.CustonSpinner
android:id="#+id/faq_contato_spinner_assunto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:hintText="#string/title_spinner" />
<EditText
android:id="#+id/faq_contato_campo_mensagem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:gravity="center_horizontal|bottom"
android:hint="#string/hint_areamensagem"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/faq_contato_numero_caracteres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="#string/caracteres" />
<com.google.android.material.button.MaterialButton
android:id="#+id/faq_contato_btn_enviar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:layout_gravity="right"
android:text="#string/enviar" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/faq_contato_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="13dp" />
</LinearLayout>
</ScrollView>
The problem is you setting a padding to your EditText, that's why the EditText components are not being given enough space to accommodate user's input without having to overlay with the hint. Simply get rid of paddings in your EditText components and it will run just fine. :)
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
If you DO NOT want your hint to float. (If you want your hint to completely disappear as soon as the user taps on the EditText box)
You can add app:hintEnabled="false" in your TextInputLayout.
In this case, I think you can safely add your padding back on because the hint will disappear on user's tap.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dp"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
Try with the following code may be it will help you.
//Remove padding from edittext
//Try to set hint on TextInputLayout instead of EditText
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_nome_contato">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:lines="1"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>

Android SearchView overlapping

I need to build a searchview who is fixed on top of the page.
When i scroll down my searchview is overlapped by a imageslider Image 1 all i need to do is to be always in front to be visible.
I tried everything but always my searchview is in the back of other objects. Any suggestions?
This is my xml file.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/email"
android:drawableStart="#drawable/email"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/parola"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/parola"
android:inputType="textPassword"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="#color/white"
android:paddingStart="30sp"
android:textColor="#color/white" />
</LinearLayout>
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_period="1000"></com.denzcoskun.imageslider.ImageSlider>
</LinearLayout>
</ScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
You can use elevation to make it at top of other elements
Solution Code:
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:elevation="20dp"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
For instance, I used 20dp, you use your preferred value instead.
Feel free to ask if something is unclear.

AndroidStudio - TextInput hide characters when keyboard shows up

When I try to enter characters in my TextInputEdit I can't see them while keyboard is shown up.
It happens only with the last textinputedit in my activity, other works perfectly. When I hide my keyboard - characters appears, but when I try to add some again I cant see any changes until keyboard hides.
My xml of activity:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".Registration"
android:id="#+id/app_bar">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regEmailwrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Your Email *"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regNamewrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regEmailwrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="First name" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regSurnameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regNamewrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regSurname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Last name" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regPasswordwrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regSurnameWrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Password *"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regPassword2wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regPasswordwrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regPassword2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Password again *"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/signUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Sign up!"
app:layout_constraintTop_toBottomOf="#+id/genderDropdown"
tools:layout_editor_absoluteX="0dp" />
<Spinner
android:id="#+id/genderDropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:spinnerMode="dropdown"
app:layout_constraintTop_toBottomOf="#+id/regPassword2wrapper"
tools:layout_editor_absoluteX="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
How can i fix it?
Add this properties :
android:windowSoftInputMode="adjustPan|adjustResize"
to your Activity tag in AndroidManifest.xml
You can wrap your ConstraintLayout inside ScrollView so you can easily scroll view when you can't see TextInput
<ScrollView 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:fillViewport="true">
This should be enough. I think there's no need to add anything inside Manifest

How can I convert an XML to make a programmatically view in Android Java

I made a design for a comment section in XML, but I want to create it programmatically when I get some data from database. How can I convert all of these to Java?
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:cardCornerRadius="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/complete"
android:scaleType="centerCrop"
android:layout_gravity="center">
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.75" >
<TextView
android:id="#+id/commentFullname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calin Onaca:"
android:textColor="#000"
android:layout_gravity="center"/>
<TextView
android:id="#+id/commentReply"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:textColor="#000"
android:text="So Bleesed i choosed him no matter what you say i will always choose him"/>
<com.google.android.material.button.MaterialButton
android:id="#+id/postReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reply"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:text="Reply: "/>
<TextView
android:id="#+id/replyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:text="Thank you very much my dear" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
All the texts will be displayed from database. I know it sounds stupid, but I'm a begginer and I really don't know how to do this. :) Thank you in advance!
Use one of the LayoutInflater inflate methods that best satisfies your use case. The below example will create View containing your layout.
View commentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.comment_layout,null);

Single layout file and single java file for Both Activity and it's Fragment

Is it a good approach to define both the activity and fragment layout in the same .xml file like this?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="#+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context="com.vitealth.android.LoginActivityPatient"
tools:ignore="MergeRootFrame">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.vitealth.android.LoginActivityPatient$LoginActivityFragment"
android:orientation="vertical"
android:gravity="center"
android:weightSum="1"
android:background="#ff8cc86a">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.7">
<ImageView
android:layout_width="1156dp"
android:layout_height="wrap_content"
android:src="#mipmap/pockedoc_login"
android:id="#+id/icon_login"
android:layout_gravity="center"
android:cropToPadding="false" />
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="0.3">
<TextView
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/Invalid_indicator_tv"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Username"
android:textSize="15dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffffff"
android:background="#26454545"
android:textSize="20dp"
android:singleLine="true"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:id="#+id/username_textbox"
style="#style/EditTextTheme"/>
<TextView
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textSize="15dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffffff"
android:background="#26454545"
android:singleLine="true"
android:password="true"
android:textSize="20dp"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
style="#style/EditTextTheme"
android:id="#+id/password_textbox"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login as Patient"
android:id="#+id/login_button_patient"
android:textColor="#ffffffff"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:backgroundTint="#fff43d2c"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sign Up as Patient"
android:textColor="#ff3348ff"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="50dp"
android:id="#+id/signup_button_patient"
android:backgroundTint="#fffdfdfd" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
if yes, then why does android studio, by default, make separate files for them if you make activity with fragments?
Similarly, would it be wise to make a single java file for both activity and fragment? Why?
obviously, it is not good to have activity and fragment layout in the same .xml
Why?
Because why use fragment when your activity contains the same layout which is there in fragment XML.also if you use this type of views then your activity be used for the only specific to that fragment views only which is not the actual use of fragment.you can't add any other fragment in that activity if you do as you mentioned

Categories

Resources