Paste Text Field and Button over an ImageView in LinearLayout - android

This is the login activity I want to achieve in my app (Image2). But I do not know how to do so it because I cannot paste the editText, password and button over the white part of the image (the whole image has black border). The app has white background and I want to make the look of the image as curve and to place the other fields under it. For now it looks as image1.
and look this
I also want my image to be aligned to the bottom and its width to be match_parent and the height to be adjusted so that the ratio of the original image is saved on different devices. Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/banner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
tools:context="com.example.android.start.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
app:srcCompat="#drawable/logo"
android:id="#+id/logo"
android:layout_weight="2"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:id="#+id/back"
app:srcCompat="#drawable/image2"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/editText3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="#+id/editText2" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button"
android:layout_centerInParent="true"/>
</LinearLayout>

You can do something like this
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/banner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
tools:context="com.example.android.start.MainActivity">
<ImageView
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
app:srcCompat="#drawable/logo"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center"
app:srcCompat="#drawable/image2">
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:inputType="textPassword"/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button"/>
</LinearLayout>

Use RelativeLayout instead of LinearLayout it will hopefully solve your problem.

Here is the code I used to achieve the look from Image2:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/banner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
tools:context="com.example.android.start.MainActivity">
<ImageView
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
app:srcCompat="#drawable/logo" />
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#drawable/back"
android:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#C8E6C9"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName"
android:layout_marginBottom="117dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:text="Sign In"
android:background="#8BC34A"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="11dp" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#C8E6C9"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:layout_above="#+id/button"
android:layout_alignLeft="#+id/name"
android:layout_alignStart="#+id/name"
android:layout_marginBottom="19dp" />
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>

Related

How to add a textview towards left and edittext towards right inside a background with delete button near to the background android

Below is the image what I required.
You can see there is blue background and inside that, it has
Trailer Number 1 which is textview and 01010 is editext (input field)
Also outside the background, there is delete button near to the blu background.
What I tried is,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#color/app_white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/relative_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue_light"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp">
<TextViewÃ’
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trailer number"
android:padding="#dimen/margin_5"
android:layout_margin="5dp"
android:layout_alignParentLeft="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:text="01010"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="0dp"
android:layout_toRightOf="#+id/relative_1"
android:background="#drawable/ic_delete_cion" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
But delete icon is not at all displaying and also line is displaying in 01010 eddittext.
This is my screenshot.
I made some changes in ur layout and it is fit in ur requirement and fit for every device.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/relative_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/default_blue_light">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|start"
android:padding="10dp"
android:text="Trailer number" />
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:background="#null"
android:inputType="number"
android:padding="5dp"
android:text="01010"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/ic_delete_icon" />
</LinearLayout>
you can achive this by only putting android:weightSum into linear layout.
try below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_white"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight=".9"
android:background="#color/blue_light"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".7"
android:text="Trailer number" />
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="#null"
android:inputType="number"
android:text="01010"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight=".1"
android:layout_gravity="center"
android:background="#drawable/ic_delete_cion" />
</LinearLayout>
Try this xml code : (Please replace dimensions, padding, styles with your own)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#FFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/relative_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_weight="6"
android:background="#f5f5f5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:gravity="center_vertical"
android:padding="5dp"
android:text="Trailer number" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:inputType="number"
android:text="01010" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:src="#drawable/ic_delete_black_24dp" />
</LinearLayout>
</LinearLayout>

LinearLayout not scrolling when keyboard is appearing

I am facing a problem with ScrollView. When the keyboard is appearing, scrollview is not scrolling till the end of the view.
Here is my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="#dimen/heading_text_size"
android:background="#color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="#+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="#+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="#dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I have seen several posts in stackoverflow, but unfortunately none is working. What could be the possible solution?
Thanks in advance.
I think the problem is causing by adjustPan . Where adjust Pan does not resize the window, it pans the view so that whatever has focus is never obscured by the soft keyboard.
Add this to your AndroidManifest.xml . This might do the trick.
Example:
<activity android:name="YourActivity"
android:windowSoftInputMode="adjustResize" />
you need to add <Space/> and
android:layout_height="100dp"
give height static which you want.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="#dimen/heading_text_size"
android:background="#color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="#+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="#+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="#dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
</ScrollView>
</LinearLayout></LinearLayout>
Use this in your layout:
android:layout_marginBottom="16dp"

Is this a real bug?

I don't know why, but my layout color just stops in the bottom of the screen.
I don't think my code is doing that.
And, by the way, does anyone know where to get ideas from a simple layout like this? TextViews and EditTexts?
Mine looks awful
<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"
android:background="#color/AMOB_gray"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/material"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/snipperMaterial">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/diameter"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<EditText
android:id="#+id/et_diameter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/thickness"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_thickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clr"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_clr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<Button
android:id="#+id/btn_save_tube"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_buttons"
android:text="#string/save"
android:textColor="#color/AMOB_gray"
android:layout_marginTop="10dp"/>
</LinearLayout>
</ScrollView>
Instead of this:
<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"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
Try this
<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"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment"
android:background="#color/AMOB_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center">
So to move the background color inside the root ViewGroup
Add below line in your scroll view. This will do what you want
android:fillViewport="true"

Put the button on the bottom center of the screen with the RecyclerView

I have RecyclerView and Button. Button is coming under the recyclerView. I want to put the button to the bottom center of the screen in my screen. That should not change in any device. Because in some devices button get disappear.
My Xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33DADADA"
android:fitsSystemWindows="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<include
android:id="#+id/app_bar"
layout="#layout/app_toolbar"></include>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#4dabf5"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distribution Channel "
android:textSize="18sp" />
<Spinner
android:id="#+id/selectDistribChannel"
android:layout_width="150dp"
android:layout_height="wrap_content"></Spinner>
</LinearLayout>
<AutoCompleteTextView
android:id="#+id/autoCompleteTextView"
android:layout_width="320dp"
android:layout_height="35dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/rounded_edittext"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:hint="Search Products"
android:singleLine="true" />
<android.support.v7.widget.RecyclerView
android:id="#+id/selectedItemRecyclerView"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#33DADADA"
android:padding="5dp">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom">
<Button
android:id="#+id/bAdd"
android:layout_width="250dp"
android:layout_height="48dp"
android:text="Send"
android:textColor="#color/btn_login" />
</LinearLayout>
</LinearLayout>
Try this (replace by Relativelayout)-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/bAdd"
android:layout_width="250dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:text="Send"
android:textColor="#color/btn_login" />
</RelativeLayout>
Let me know if this works
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.RecyclerView
android:id="#+id/selectedItemRecyclerView"
android:layout_above="#id/button"
android:layout_weight=1
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#33DADADA"
android:padding="5dp">
</android.support.v7.widget.RecyclerView>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:text="write your text"
android:textColor="#color/colorPrimary" />
</RelativeLayout>

how to move username and password layout move when touching in android

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>

Categories

Resources