I'm trying to center my layout so there's an equal amount of space on the right and left side. Currently, everything is left aligned. I've tried setting layout_gravity to center_horizontal for all my widgets/elements but that doesn't work. Can someone explain what I'm doing wrong? Here's my code:
<FrameLayout 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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center_horizontal">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/scored"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/percent"
android:textSize="20sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
</TableLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/calculate" />
</LinearLayout>
</FrameLayout>
You can remove all other gravity attributes you set.
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"> <---- HERE
Related
I want the screen to automatically scroll up when the keyboard opens, so that the user can see what he has written.
The solution I found was to change the manifest and use adjustPan or adjustResize. I used both of them but it still didn't work.
Where is my mistake?
Thanks in advance.
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#color/white"
tools:context=".auth.LoginActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="#mipmap/img_login"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
tools:ignore="MissingConstraints" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
android:orientation="vertical"
android:background="#drawable/login_back">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="#color/customColor"
android:gravity="center"
android:textSize="30dp"
android:layout_marginTop="42dp"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:focusableInTouchMode="true"
android:hint="User Name"
android:layoutDirection="rtl"
android:textColorHint="#color/customColor"
>
<EditText
android:id="#+id/acLogin_edtUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:inputType="textEmailAddress"
android:textSize="16dp"
android:singleLine="true"
android:textColor="#color/customColor"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:focusableInTouchMode="true"
android:hint="Password"
android:layoutDirection="rtl"
android:textColorHint="#color/customColor"
>
<EditText
android:id="#+id/acLogin_edtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textSize="16dp"
android:textColor="#color/customColor"
/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="42dp"
android:layout_gravity="center"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="#color/customColor"
app:cardCornerRadius="8dp">
<TextView
android:id="#+id/acLogin_txtLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Login"
android:textColor="#ffffff"
android:textSize="18dp" />
<ProgressBar
android:id="#+id/acLogin_prgLoading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="gone" />
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="48dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Don't have any account?"
android:gravity="bottom"
android:layout_marginLeft="58dp"
android:textColor="#color/customColor"
android:textSize="16dp"/>
<TextView
android:id="#+id/acLogin_txtSignUp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:gravity="bottom"
android:text="Sign Up"
android:textColor="#color/customColor"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="200dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I change manifest to:
<activity android:name=".auth.LoginActivity"
android:windowSoftInputMode="adjustPan | adjustResize"/>
I am struggling to know why my imageView won't appear above the tableLayout.
as part of my assessment I must use RelativeLayout and not linearLayout and I am supposed to set an image above a TableLayout and it isn't working.
This is my code:
<RelativeLayout 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="com.mad.exercise3.MainActivity">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="#dimen/imageSize"
android:layout_marginTop="20dp"
android:contentDescription="#string/imageDescription"
app:srcCompat="#mipmap/ic_launcher_round"
android:layout_alignParentTop="true"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_fn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/TextView_fn" />
<EditText
android:id="#+id/editText_fn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_ln"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewText_ln" />
<EditText
android:id="#+id/editText_ln"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/textView_phone" />
<EditText
android:id="#+id/editText_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="phone" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/textView_email" />
<EditText
android:id="#+id/editText_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textEmailAddress" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp">
<Button
android:id="#+id/swapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/swapBtn" />
<Button
android:id="#+id/rotateBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rotateBtn" />
</LinearLayout>
and this is what android studio is displaying.
result
For some reason the imageView and the tableLayout are appearing in the same area, even though I set image view to alignParentTop.
use an id for the tablelayout then from your image add: android:layout_above:"id/tablelayout"
Try this
<RelativeLayout 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="com.mad.exercise3.MainActivity">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:contentDescription="#string/imageDescription"
app:srcCompat="#mipmap/ic_launcher_round"
android:layout_alignParentTop="true"/>
<TableLayout
android:layout_below="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_fn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/TextView_fn" />
<EditText
android:id="#+id/editText_fn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_ln"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewText_ln" />
<EditText
android:id="#+id/editText_ln"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/textView_phone" />
<EditText
android:id="#+id/editText_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="phone" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/textView_email" />
<EditText
android:id="#+id/editText_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:inputType="textEmailAddress" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp">
<Button
android:id="#+id/swapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/swapBtn" />
<Button
android:id="#+id/rotateBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/rotateBtn" />
</LinearLayout>
Add android:layout_height="wrap_content" to your imageview, and android:layout_below="#+id/image" to TableLayout
this is my xml file layout when keyboard is open my bottom view also scroll
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_school"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/_14sdp"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:hint="School Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/edt_education_degree"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Degree" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_field_of_study"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Field Of Study" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="wrap_content"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_start_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Start Date"
android:inputType="number"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_end_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="End Date"
android:inputType="number"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_activities"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Activities" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_education_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/button_selector"
android:text="Save"
android:visibility="gone"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/tv_delete_education"
android:layout_width="match_parent"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentBottom="true"
android:layout_marginTop="#dimen/_10sdp"
android:gravity="center"
android:visibility="gone"
android:textColor="#222222"
android:textSize="#dimen/_16sdp"
android:text="Delete Education" />
when i open the keyboard my textview (tv_delete_education) is override on text
i want to fix my textview in bottom navigation no required to scroll. i also add in menifest file adjustPan ,adjustResize but still not work for me if any kind of help let me know thanks in advance
use this in android manifest android:windowSoftInputMode="adjustNothing"
for activity.It will solve your problem.
Here is basic format for your design and its working.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.example.whiz_010.myapplication.ui.home.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Company"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Location"
/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Start Date"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="End Date"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Delete Experience"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
AndroidManifest.xml
<activity
android:name=".ui.home.MainActivity"
android:windowSoftInputMode="adjustPan"/>
My English is poor. So I threw off the video. I think any programmer looking at this will understand the reason. Thank you in advance
I want to learn how to use ReleaseativeLayout correctly, because ConstainLayout is very buggy. Even using it in Android Studio Canary.
So I'm using ReleativeLayout and LineartLayout now. These are the most effective ViewGroup. I thought. But it turned out all wrong
XML Code
<RelativeLayout
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:gravity="center"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>
Just add one more Relative Layout below of your parent layout and set Gravity to it
<RelativeLayout
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:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<RelativeLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
</RelativeLayout>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
Only parent layout height and width would match parent instead of a child.
you've have entered FrameLayout height="match_parent"
you've to implement like this.
<RelativeLayout
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:gravity="center"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>
Below is what my screen looks like:
You can see that in row 1, the two buttons are not aligned evenly since the right box is 2 lines and the left box is 1 line. Also, you can see in row 3 that the buttons are wider since they are both 3 lines each.
Is there a way to make the rows the same height? Sort of like how in a LinearLayout you can use android:layout_width="#". I have posted all the code in my XML since it is relatively short.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativelayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="1dp"
android:paddingBottom="50dp"
android:background="#drawable/scroll" >
<TextView
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="14sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="65dp" />
<TextView
android:id="#+id/subHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header"
android:textStyle="italic|bold"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingBottom="20dp" />
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/subHeader"
android:layout_alignParentBottom="true"
android:background="#drawable/scrollviewborder"
android:fillViewport="true"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:paddingBottom="8dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="#+id/jc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/tencommandments"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="#+id/exodus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/genesis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="#+id/holydays"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/facts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="#+id/random"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
</TableLayout>
</RelativeLayout>
Here's your layout, redone. You're going to want to add the lines referring to your drawables in -- I took them out since I didn't have access to them. Pay attention to how the values for weight are fractional, and think of the amount of space available to a widget within a container in terms of a percentage of that space. This paradigm shift should elevate your understanding of the weight attribute.
Also, try to avoid using fill_parent, which has been deprecated in favor of match_parent in API 8 and above unless your really want to support old, moldy versions of Android (less than 1% of the installed base).
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativelayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="1dp"
android:paddingBottom="50dp" >
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="14sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="65dp" />
<TextView
android:id="#+id/subHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header"
android:textStyle="italic|bold"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingBottom="20dp" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/subHeader"
android:layout_alignParentBottom="true"
android:fillViewport="true"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:paddingBottom="8dp" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".25" >
<Button
android:id="#+id/jc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/tencommandments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".25" >
<Button
android:id="#+id/exodus"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/genesis"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".25" >
<Button
android:id="#+id/holydays"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
<Button
android:id="#+id/facts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".25" >
<Button
android:id="#+id/random"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="14sp" />
</TableRow>
</TableLayout>
</RelativeLayout>
Try to change android:layout_height="wrap_content" to match_parent in your button with the id jc.