So I have 5 EditText's and the virtual soft keyboard work almost fine with the windowSoftInputMode="adjustPan" but the 4th EditText element is hidden (by the keyboard) when I hit 'next' to go to the next edit text.
*only when I start writing the UI gets up and I can see the EditText
XML Code: (The problematic element is the EditText with 'email' id.)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:minWidth="25px"
android:minHeight="25px"
android:weightSum="5">
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/user_container"
android:gravity="right"
android:layout_weight="0">
<TextView
android:text="Register"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:id="#+id/textView1"
android:textColor="#FFFFFF"
android:gravity="right" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1"
android:background="#ffffff"
android:layout_weight="0">
<ImageView
android:src="#drawable/logo_full"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:padding="40dp"
android:id="#+id/imageView1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2"
android:gravity="top"
android:layout_weight="3">
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/keycode_container"
android:gravity="center"
android:layout_marginBottom="0.5dp"
android:layout_weight="1">
<ImageView
android:src="#drawable/keycodelogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/keycode_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/keycode"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#id/keycode_lable"
android:inputType="text"
android:hint="קוד רישום"
android:gravity="right"
android:textColorHint="#d9e5f3"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/user_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/userlogo"
android:layout_width="22dp"
android:layout_height="22.0dp"
android:id="#+id/user_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/user"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#id/user_lable"
android:hint="#string/username"
android:inputType="text"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/pass" />
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pass_container"
android:gravity="center"
android:layout_marginBottom="0.5dp"
android:layout_weight="1">
<ImageView
android:src="#drawable/passlogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/pass_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/pass"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#+id/pass_lable"
android:inputType="textPassword"
android:gravity="end"
android:hint="#string/password"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/email"/>
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/email_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/maillogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/email_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/email"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:inputType="text"
android:layout_toLeftOf="#+id/email_lable"
android:hint="#string/email"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/email"/>
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/mobilelogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/phone_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/phone"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#+id/phone_lable"
android:hint="#string/phone_num"
android:gravity="end"
android:inputType="phone"
android:textColorHint="#d9e5f3"
android:textColor="#fff" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/register_container"
android:gravity="center"
android:layout_weight="1">
<Button
android:text="Register"
android:layout_width="132.0dp"
android:layout_height="42.5dp"
android:id="#+id/register"
android:background="#drawable/loginbutton"
android:textColor="#color/black"
android:textStyle="bold"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
What can cause this?
tl;dr softKeyboard hides only 1 element out of five, and its the one with 'email' id.
So thanks to #Jay_Thummar I solved the problem.
wrapping the layout with ScrollView and changing the SoftInputMode to AdjustResize it worked.
Related
I'm trying to stack two vertical LinearLayout in LinearLayout horizontally.
My code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horisontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Also everything looks as I and has conceived:
And the scheme for full understanding:
But when I compile that in VS2015 see error "String types not allowed (at 'orientation' with value 'horisontal')". Need help
Its a typo.
Change,
android:orientation="horisontal"
to
android:orientation="horizontal"
In the root use below attribute
wheightSum="10"
and in child view use wheight = "5" for each child view
Note: on base layout use android:orientation="horizontal" for horizontal display or android:orientation="vertical" for vertical display
Error in LinearLayout orientation.It should be horizontal or remove this.(By default Linear layout has horizontal orientation. )
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hi in the below code i have these layout. once touch inside username edittext i want to move full layout upwards.onfousing the keyboard should be stay like that want to move full layout upwards
Can any one help me
layout
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
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="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/texture">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="vertical"
android:id="#+id/login">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="100dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#6E6864"
android:text="Sign in to continue"
android:id="#+id/login_tv_sign_continue" />
<EditText
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:hint="User Name"
android:id="#+id/login_ed_username"
android:background="#drawable/edit_text_back"
android:imeOptions="actionNext"
android:singleLine="true"
/>
<EditText
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:hint="Password"
android:id="#+id/login_ed_password"
android:background="#drawable/edit_text_back"
android:imeOptions="actionDone"
android:singleLine="true"
android:inputType="textPassword"
/>
<Button
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:textColor="#6E6864"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/login_btn_login"
android:text="Sign In"
android:background="#ECBC3B"
/>
<TextView
android:layout_width="300dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/txt_forgetpwd"
android:text="Forgot Password?"
android:gravity="right"
android:layout_marginTop="20dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/logo"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
I'm trying to add a header to my layout and I don't want the gap between two layouts.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linearLayoutContainer"
android:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fixed Header"
android:textColor="#ff00ff"
android:background="#00ff00" />
<ScrollView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:id="#+id/scrollView">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayoutContainer"
android:gravity="center">
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_top_bg"
android:padding="10dp"
android:hint="نــام"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_default_bg"
android:padding="10dp"
android:hint="نام خانوادگي"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etNCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_default_bg"
android:padding="10dp"
android:hint="کد ملي"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bottom_bg"
android:padding="10dp"
android:hint="شماره همراه"
android:textColorHint="#bbbbbb" />
<View
style="#style/Gap" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayoutRegisterCancel"
android:layout_gravity="clip_vertical"
android:gravity="center">
<Button
android:id="#+id/btnCancel"
android:layout_width="100px"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="بي خيال"
style="#style/DefaultButtonText"
android:background="#drawable/button_default_bg"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/btnRegister"
android:layout_width="100px"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="تمومه"
style="#style/DefaultButtonText"
android:background="#drawable/button_default_bg"
android:gravity="center_vertical|center_horizontal" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
As you can see in the following image, there's gap between "Fixed Header" text view and the main layout. How can I remove this gap?
Change your scrollview android:padding="10dp" to
android:paddingTop="10dp"
android:paddingBottom="10dp"
I have a scroll view containing a Linearlayout which contains some controls.
The controls has to be centered in the main view, so I wrapped the scroll view with a RelativeLayout and set the android:layout_centerInParent="true" which works fine.
The problem is that when I try to enter a text in the first Edittext and the tablet is in landscape mode and the keyboard appears, then the Editbox disappears and you are not able to scroll up to see the first Editbox. (I think the reason is the android:layout_centerInParent="true")
How can I solve this problem to be able to scroll up and down to see all the controls when the keyboard appears.
The Layout file is the following:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout1">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:paddingBottom="20dp"
android:scrollbarStyle="outsideOverlay"
android:layout_centerInParent="true" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center">
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="0dp"
android:layout_height="0dp"
android:id="#+id/LayoutDummy" />
<TextView
android:text="#string/Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/textView4" />
<EditText
android:inputType="textPersonName"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/EdName" />
<TextView
android:text="#string/Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/textView4" />
<EditText
android:inputType="textPersonName"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/EdName" />
<TextView
android:text="#string/Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/textView5" />
<EditText
android:inputType="textPassword"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/EdPassword" />
<TextView
android:text="#string/Mandant"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/textView5" />
<EditText
android:inputType="numberSigned"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/EdMandant" />
<EditText
android:inputType="textNoSuggestions"
android:layout_width="359.2dp"
android:layout_height="wrap_content"
android:id="#+id/EdLoginUrl"
android:layout_marginTop="11.6dp" />
<CheckBox
android:text="Offline"
android:id="#+id/cbOffline"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="7.9dp" />
<TableLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tableLayout1"
android:paddingTop="20dp">
<TableRow
android:id="#+id/tableRow1"
android:layout_gravity="center_horizontal"
android:gravity="center">
<Button
android:text="Ok"
android:id="#+id/BtnOk"
android:layout_column="0"
android:layout_width="100dp" />
<Button
android:text="Cancel"
android:layout_column="1"
android:id="#+id/BtnCancel"
android:layout_width="100dp" />
</TableRow>
</TableLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/linearLayout1"
android:paddingTop="20dp">
<Button
android:id="#+id/BtnSetting"
android:layout_height="36dp"
android:layout_width="36dp"
android:layout_gravity="center"
android:background="#drawable/ic_action_settings"
android:gravity="top" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtResult"
android:gravity="center"
android:paddingTop="20dp" />
</LinearLayout>
</LinearLayout></ScrollView></RelativeLayout>
try using linear layout instead of relative layout with
android:layout_gravity="center"
Try putting
android:windowSoftInputMode="adjustResize"
inside your activity defined in manifest file.
I am new to Android and trying to build a login box, and experience some troubles. I created two textes (Username, Password) and two text-boxes next to them, to style a login box area.
But unfortunately the elements jump up and down in correlation with the upper and lower bars, that are shown when the user touches the screen.
How can I realize a centered login box?
Link: maximize image
Here is some code:
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout android:id="#+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/login_button" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical|center_horizontal">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:baselineAligned="false"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_centerInParent="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_column="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_column="1" />
</TableRow>
</TableLayout>
</RelativeLayout>
</FrameLayout>
There is no need of Table Layout It simply done with relative and linearlayout.
http://www.androidhive.info/2011/10/android-login-and-registration-screen-design/
Use this -
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_column="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_column="1" />
</TableRow>
</TableLayout>
</RelativeLayout>
<Button
android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:text="#string/login_button" />
</FrameLayout>
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:id="#+id/editText"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textPassword"
android:ems="10"
android:layout_marginLeft="5dp"
android:id="#+id/editText3"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="#+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#color/black_overlay">
<Button android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_button" />
</LinearLayout>
</LinearLayout>