How to work Parent layout click to all child layouts? - android

In my application, I have a bottom menu So I have implemented the bottom layout for all the screens. I have one red button for the menu visible and gone, This functionality is working fine. But here my one more requirement is when clicking on the screen(outside the menu) a bottom menu will disappear. In my screens so many child layouts are available. here my parent layout is Coordinator layout. So I have created to id to Coordinator layout and Implemented OnClick listener for this one. So In OnClick, I will disappear the menu.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:id="#+id/coord_layout"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/fgtrellayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/topBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorScreenBG"
android:orientation="horizontal">
<include
android:id="#+id/action_bar"
layout="#layout/custom_action_bar">
</include>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/topBanner"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:background="#color/colorScreenBG"
android:orientation="vertical">
<TextView
android:id="#+id/instctsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_marginRight="7dp"
android:text="#string/forgotPasswordAlert"
android:textColor="#040101"
android:textSize="#dimen/normal_font_size" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<android.support.design.widget.TextInputLayout
style="#style/MyTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="#+id/fgtActNoVal"
style="#style/MyTextInputEditText"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:hint="#string/acctNo_UserId"
android:imeOptions="actionNext"
android:singleLine="true"
android:inputType="text"
android:maxLength="30"
android:maxLines="1"
android:textColor="#android:color/black"
android:textSize="#dimen/normal_font_size" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
style="#style/MyTextInputLayout"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="#+id/fgtTelVal"
style="#style/MyTextInputEditText"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:hint="#string/tel_No"
android:imeOptions="actionDone"
android:singleLine="true"
android:inputType="number"
android:maxLength="4"
android:maxLines="1"
android:textColor="#android:color/black"
android:textSize="#dimen/normal_font_size" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_gravity="center_horizontal"
android:id="#+id/dgtsLmt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastFourDigits"
android:textColor="#ff0000"
android:textSize="#dimen/tenfont" />
<CheckBox
android:id="#+id/mailcheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="#string/emailMyPassword"
android:textColor="#040101"
android:textSize="#dimen/normalLayout"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:id="#+id/btnsLayot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp">
<android.support.design.button.MaterialButton
style="#style/MyButton"
android:id="#+id/fgtClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/back"
android:textAllCaps="false"/>
<android.support.design.button.MaterialButton
style="#style/MyButton"
android:id="#+id/fgtReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="#string/reset"
android:textAllCaps="false"/>
<android.support.design.button.MaterialButton
style="#style/MyButton"
android:id="#+id/fgtSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="#string/submit"
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<include layout="#layout/bottom_sheet_login"
android:visibility="visible" />
</android.support.design.widget.CoordinatorLayout>``
So in the above xml, Coordinator layout on click is working fine. But if the layout having listview or webview then parent layout on click is not working
This is the xml file
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:id="#+id/coord_layout"
android:background="#color/colorScreenBG"
android:layout_height="fill_parent"
android:layout_marginBottom="0dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/total_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:orientation="vertical">
<include
android:id="#+id/topBanner"
layout="#layout/custom_action_bar"></include>
<RelativeLayout
android:id="#+id/NoticeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/locations1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dip"
android:text="#string/noInfoExists"
android:textColor="#C00000"
android:textSize="#dimen/normalHeadings" />
<ListView
android:id="#+id/locations"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="2dp"
android:background="#00000000"
android:cacheColorHint="#00000000"
android:textColor="#040101" />
</RelativeLayout>
</LinearLayout>
<include
layout="#layout/bottom_sheet_login"
android:visibility="visible" />
</android.support.design.widget.CoordinatorLayout>
In my application, so many screens are there. When clicking on the screen(Outside the menu) the menu will disappear. So how to work parent layout on click for all the child views.
Check the bellow image
So please help with this.
Thanks In Advance

First, add those to your root view for touchable area.
android:focusableInTouchMode="true"
android:clickable="true"
android:focusable="true"
After that, you can use onFocusChanged listener to handle your views' behaviour.

Related

How to make the lower navigation bar show what's the last thing in the activity?

I was trying to make a lower navigation bar and because the views where a lot I needed to use a scroll view but the problem is that the last element in the scroll view doesn't appear because of the navigation bar.
so what can I do to make last element appear??
my xml code is :
<?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:background="#E6E6E6"
android:layout_height="match_parent"
tools:context=".mainPage">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<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:layout_margin="16dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="#font/lato_bold"
android:text="Servings"
android:textColor="#color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="#+id/servings"
android:hint="Servings that you will eat"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="#font/lato_bold"
android:text="grams per serving"
android:textColor="#color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="#+id/grams"
android:hint="grams per serving"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="#font/lato_bold"
android:text="calories for each serving"
android:textColor="#color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="#+id/calories"
android:hint="calories for each serving"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="#font/lato_bold"
android:text="meal name"
android:textColor="#color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="text"
android:id="#+id/name"
android:hint="type the meal name"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/add"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/lato_bold"
android:text="Add"
android:textSize="14sp" />
<Button
android:id="#+id/dont"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/lato_bold"
android:text="Don’t know how many calories are in this meal ?"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="#+id/main_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/lato_bold"
android:text="What have you eaten today"
android:textSize="14sp" />
<Button
android:id="#+id/adding_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/lato_bold"
android:text="Food Adding"
android:textSize="14sp" />
<Button
android:id="#+id/profile_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/lato_bold"
android:text="Profile"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
so how can I make the last element in the scroll view because the navigaion bar is blocking it (it's in the front of it so the last element doesn't show.
This is an image of it and as you can see the navigation bar is in the front of the last element so it doesn't show because of that
Add id to Bottom navigation bar LinearLayout
Add android:layout_above="#+id/yourbottomlayoutid" , android:layout_height="match_parent" and android:fillViewport="true" to your ScrollView.
For reference check below 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:background="#E6E6E6"
android:layout_height="match_parent"
tools:context=".mainPage">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_above="#+id/llBottomBar">
<!--Your LinearLayout-->
</ScrollView>
<LinearLayout
android:id="#+id/llBottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<!--Bottom navigation bar buttons-->
</LinearLayout>
</RelativeLayout>
Add android:paddingBottom = "Xdp", where X is something bigger than your bottom bar, to the last LinearLayout.
Example: android:paddingBottom = "30dp"

edittext must move up on the top of the keyboard without moving other views

[This is the image i need to move up only edittext not the logo ][1]edittext appearing on the top of the keyboard after setting windowSoftInputMode but other views also moving up. is their any way to move only edittext .Thanks in advance
[1]: https://i.stack.imgur.com/NEpf3.png`
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="#drawable/logo_light"
android:text="LOGO"
android:textColor="#color/black"
android:textSize="100dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/ll_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:orientation="horizontal">
<EditText
android:id="#+id/editMessage"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:background="#color/white"
android:gravity="center"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:hint="EDIT TEXT"
android:minLines="3"
android:textColorHint="#color/black"
android:scrollHorizontally="false"
android:textColor="#color/white" />
<Button
android:id="#+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#color/black"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
`
Try to use framlayout and xml like below
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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" >
<EditText
android:id="#+id/edit_text_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_vertical"
android:layout_marginLeft="12dp"
android:background="#null"
android:layout_alignParentBottom="true"
android:hint="Enter you something"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="2000"
android:maxLines="8" />
</FrameLayout>
If your using relative layout , in the edit text tag add this.
android:layout_alignParentBottom="true"

Duplicate the some part of layout each time the button is clicked in android

I have a layout that contains edit text fields and spinner in a linear layout.And i have button in relative layout.So each time the button is clicked i want to duplicate only the linear layout part with id linear_layout_add_more.Here is my exml layout.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D3D3D3"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Toolbar">
<Button
android:id="#+id/next1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right|top"
android:layout_margin="10dp"
android:background="#drawable/ic_navigate_next" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/rl_add_more"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_layout_add_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#android:color/white"
android:elevation="5dp"
android:orientation="vertical">
<Spinner
android:id="#+id/type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#android:drawable/btn_dropdown"
android:spinnerMode="dropdown"
android:prompt="Slect type"/>
<EditText
android:id="#+id/edit_text_add_more_quantity"
style="#style/App_EditTextStyle"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:backgroundTint="#2FAA96"
android:hint="Quantity"
android:imeOptions="flagNoExtractUi"
android:inputType="number" />
<EditText
android:id="#+id/edit_text_add_more_description"
style="#style/App_EditTextStyle"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:backgroundTint="#2FAA96"
android:hint="Description"
android:imeOptions="flagNoExtractUi"
android:singleLine="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Select timer value"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:weightSum="2">
<EditText
android:id="#+id/timer_days"
style="#style/App_EditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#2FAA96"
android:hint="Days"
android:inputType="number" />
<EditText
android:id="#+id/timer_hours"
style="#style/App_EditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#2FAA96"
android:hint="Hours"
android:inputType="number"
android:nextFocusDown="#id/edit_text_add_more_quantity"
android:nextFocusUp="#id/edit_text_add_more_quantity" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:clickable="true"
android:src="#drawable/icon_add"
app:backgroundTint="#ee2f5a"
app:elevation="10dp"
app:rippleColor="#android:color/white" />
</RelativeLayout>
</ScrollView>
`
Move the linear layout part with id linear_layout_add_more in listview layout. And include this listview in your xml.
On button click increse the listview item size and call notifydatasetchanged on listview adapter
You can create a parent view in your layout
<LinearLayout
android:id="#+id/duplicate_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
> </LinearLayout>
and create a seperate layout which will contains all view you wants to add repetitively for example child_layout.xml. Now on click of button you can inflate child_layout.xml and add it to duplicate_view_container.

ScrollView: Button is not visible completely

I have a Problem with one activity xml in my Android project.
Its a ScrollView and inside i have a LinearLayout. In the LinearLayout i added a Button.
But the button is not completely visible. Only 2px or like that.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/image_view_one"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titel"
android:textSize="20dp"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:textColor="#000000"
android:id="#+id/textview_titel"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Content"
android:textSize="15dp"
android:layout_margin="10dp"
android:textColor="#000000"
android:id="#+id/textview_description"
/>
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_zum_gewinnspiel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="12dp"
android:text="ZUM GEWINNSPIEL"
android:background="?attr/colorPrimary"
android:textSize="18dp"
/>
</LinearLayout>
</ScrollView>
Give bottomPadding in LinearLayout.

How do I ensure the buttons align horizontally in this Android login dialog?

I'm creating a login dialog on Android where I want two buttons to align horizontally both on the top and bottom edge, irregardless of the screen size. Sometimes "Forgot password" will break over two lines, sometimes not. I do not want to impose a minHeight on the buttons, and would prefer a solution based on XML design only (not code).
Landscape is fine:
Portrait, default implementation leaves the login button shorter than "forgot password"
One solution I tried was setting match_parent for the layout_height param of the first button. Didn't quite work:
XML:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/terms_layout"
android:layout_marginTop="10dp"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/login"
android:textSize="18sp"
android:id="#+id/dialog_login_button_login"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/forgotPassword"
android:textSize="18sp"
android:id="#+id/dialog_login_button_forgot_password"
/>
</LinearLayout>
Use RelativeLayout and make "Login" button to align to the top and bottom of "Forgot Password" Button
As #manjusg answered, make the Login button align the bottom and top to the other button.
Here is how I did it:
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/terms_layout"
android:layout_marginTop="10dp">
<View
android:id="#+id/center_strut"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_centerInParent="true" />
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="Login"
android:textSize="18sp"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/center_strut"
android:layout_alignBottom="#+id/dialog_login_button_forgot_password"
android:layout_alignTop="#+id/dialog_login_button_forgot_password"
android:id="#+id/dialog_login_button_login" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/center_strut"
android:text="Forgot Password"
android:textSize="18sp"
android:id="#+id/dialog_login_button_forgot_password" />
</RelativeLayout>
</LinearLayout>
replace your xml with this xml
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/terms_layout"
android:layout_marginTop="10dp"
android:weightSum="2"
>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/login"
android:textSize="18sp"
android:id="#+id/dialog_login_button_login"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/forgotPassword"
android:textSize="18sp"
android:id="#+id/dialog_login_button_forgot_password"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</LinearLayout>
check this
<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"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout">
<Button
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Login"
android:id="#+id/button"/>
<Button
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="FORGOT PASSWORD"
android:id="#+id/button2"/>
</LinearLayout>
<LinearLayout
android:layout_alignBottom="#+id/linearLayout"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_height="wrap_content">
<View
android:layout_width="0.5dp"
android:layout_height="wrap_content"
android:background="#000000"/>
</LinearLayout>
</RelativeLayout>

Categories

Resources