I'm looking for an answer what should I do to prepare static layout ( without ScrollView, because when I put as a root ScrollView, then my LinearLayout is bigger than screen size, without scrollview, linearlayout is perfect ), so I have a form with 5 edittexts, and when I click on once of them, keyboard appear and now I need scroll on this form. I tried use ScrollView, android:windowSoftInputMode="adjustPan" and much more, but nothing works.
<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:background="#aa000000">
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/background"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="false" android:scaleType="centerCrop"
android:id="#+id/blueBackground"
android:background="#aa000000"
/>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="match_parent"
android:id="#+id/imageView"
android:src="#drawable/applogo"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:layout_height="60dp" android:layout_marginTop="25dp"
android:layout_weight="2"
/>
<TextView
android:text="Text1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/textView7"
android:textColor="#color/apptheme_color" android:textAlignment="viewStart"
android:gravity="center_horizontal" android:layout_marginTop="35dp" android:textSize="18sp"
android:layout_weight="1"
/>
<TextView
android:text="Text2"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/numberTextView" android:gravity="center_horizontal"
android:textColor="#color/apptheme_color" android:textSize="24sp"
android:layout_weight="1"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/edit1"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="16dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/edit2"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit2"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/edi3"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit3"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/edit4"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit4"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine|textPersonName"
android:ems="10"
android:id="#+id/edit5"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="20dp" android:paddingLeft="10dp"
android:layout_weight="3.33"
android:scrollbars="vertical" android:hint="Notatka" android:lines="2" android:textColor="#FFFFFF"/>
<CheckBox
android:text="Checkbox1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/check1" android:layout_marginLeft="20dp"
android:textColor="#color/apptheme_color"
android:layout_weight="1"
/>
<CheckBox
android:text="Checkbox2"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/check2" android:layout_marginLeft="20dp"
android:textColor="#color/apptheme_color"
android:layout_weight="1"
/>
<Button
android:text="Save"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/button" android:layout_weight="2"
android:textColor="#02485a" android:background="#drawable/blackborder"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Add ScrollView inside RelativeLayout with fillViewport property
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
</ScrollView>
Related
I have an Activity with two buttons. Button click opens a new Fragment. But the Fragment view is overlapping my Activity view.
I have tried giving background to my fragment but it is not working for me
Here is activity xml 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"
android:background="#E6E6E6"
tools:context=".TourAdmin">
<TextView
android:id="#+id/tour_admin_tour_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Tournament Name"
android:textSize="30dp" />
<Button
android:id="#+id/tour_admin_schedule"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="#+id/tour_admin_tour_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:background="#color/colorPrimary"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Schedule Match"
android:textColor="#fff" />
<Button
android:id="#+id/tour_admin_show_for_score"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="#+id/tour_admin_schedule"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#color/colorPrimary"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Score Match"
android:textColor="#fff" />
<FrameLayout
android:id="#+id/admin_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Here is fragment xml code:
<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:layout_margin="2dp"
android:background="#android:color/holo_red_dark"
tools:context=".TourScheduleMatch">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/tour_team1_select_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:paddingLeft="6dp"
android:paddingRight="6dp" />
<Spinner
android:id="#+id/tour_team2_select_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tour_team1_select_spinner"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
/>
<Spinner
android:id="#+id/tour_sched_half_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tour_team2_select_spinner"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:entries="#array/match_time"/>
<Spinner
android:id="#+id/tour_sched_nop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tour_sched_half_time"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:entries="#array/tournament_nop"/>
<EditText
android:id="#+id/tour_cityNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:layout_marginRight="24dp"
android:layout_weight="0"
android:hint="City"
android:inputType="text"
android:padding="8dp"
android:layout_below="#id/tour_sched_nop"/>
<EditText
android:id="#+id/tour_groundNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:layout_marginRight="24dp"
android:layout_weight="0"
android:hint="Ground"
android:inputType="text"
android:padding="8dp"
android:layout_below="#id/tour_cityNameEditText"/>
<LinearLayout
android:id="#+id/match_date_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#id/tour_groundNameEditText"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/tour_match_date_bn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="#color/colorPrimary"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="Match Date"
android:textColor="#fff" />
<TextView
android:id="#+id/tour_match_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="85dp"
android:layout_marginTop="28dp"
android:text="Match Date"
android:textColor="#000"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/match_time_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/match_date_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<Button
android:id="#+id/tour_match_time_bn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="#color/colorPrimary"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="Match Time"
android:textColor="#fff" />
<TextView
android:id="#+id/tour_match_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="85dp"
android:layout_marginTop="28dp"
android:text="Match Time"
android:textColor="#000"
android:textSize="20dp" />
</LinearLayout>
<Button
android:id="#+id/tour_schedule_schedule_bn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/match_time_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#color/colorPrimary"
android:text="Create"
android:textColor="#fff" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
I hope you are using a ConstraintLayout. To make the elements align one after another, use a LinearLayout or FrameLayout.
Using RelativeLayout here is wrong option. You should use LinearLayout instead. Place your FrameLayout as first view in your activity layout and change its visibility from gone to visible when needed.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E6E6E6"
android:orientation="vertical">
<FrameLayout
android:id="#+id/admin_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
<TextView
android:id="#+id/tour_admin_tour_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="60dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Tournament Name"
android:textSize="30dp" />
<Button
android:id="#+id/tour_admin_schedule"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_gravity="center_horizontal"
android:background="#color/colorPrimary"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Schedule Match"
android:textColor="#fff" />
<Button
android:id="#+id/tour_admin_show_for_score"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="#+id/tour_admin_schedule"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:background="#color/colorPrimary"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Score Match"
android:textColor="#fff" />
</LinearLayout>
Another option is using ConstraintLayout but it is harder to use than LinearLayout.
I have a problem with height of linear layout. When I use only linear layout, my form is scaled to screen size, and everything look like good. But now, I need to have scrollview only when I click an edittext and keyboard appear. I set scrollview as a root of my layout, but it extended height of this layout. Scrollview should be work only while keyboard appear, but now it work's every time and ruined my linearlayout. So right now, when I'm using a scrollview, layout is bigger than screen size. What should I do?
<ScrollView
android:layout_width="match_parent"
android:id="#+id/scrollView"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_height="match_parent"
tools:context=".activities.FormDialog"
>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:background="#drawable/new_background">
<ImageView
android:layout_width="84dp"
android:id="#+id/imageView"
android:src="#drawable/applogo"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_gravity="end" android:layout_marginRight="20dp"
android:layout_height="29dp"/>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentStart="true"
>
<TextView
android:text="Info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/missedCall"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:textColor="#color/apptheme_color"
android:layout_marginBottom="16dp" android:textSize="15sp" android:layout_marginTop="16dp"/>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_weight="2" android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp"
android:layout_marginBottom="6dp" android:weightSum="1">
<ImageView
android:text="Button"
android:id="#+id/leftButton"
android:layout_width="40dp" android:layout_height="40dp"
android:layout_gravity="center_vertical" android:src="#drawable/left"/>
<TextView
android:text="Text"
android:layout_width="244dp"
android:layout_height="match_parent" android:id="#+id/numberTextView"
android:gravity="center_vertical|center_horizontal|center"
android:textColor="#color/apptheme_color" android:textSize="24sp"
android:layout_weight="1"/>
<ImageView
android:text="Button"
android:id="#+id/rightButton"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="40dp" android:layout_height="40dp"
android:src="#drawable/right_arrow"/>
</LinearLayout>
<TextView
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/textView7"
android:textColor="#color/apptheme_color" android:textAlignment="viewStart"
android:textSize="18sp"
android:layout_weight="0.5"
android:layout_below="#+id/missedCall" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_marginLeft="30dp"
android:layout_marginRight="25dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/nameTextView"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="16dp"
android:paddingTop="10dp" android:paddingBottom="10dp"
android:hint="Edit1" android:paddingLeft="10dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/detailsTextView"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit2"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textWebEmailAddress"
android:ems="10"
android:id="#+id/emailEditText"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit3"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/companyEditText"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingLeft="10dp"
android:layout_weight="1"
android:hint="Edit4"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine|textPersonName"
android:ems="10"
android:id="#+id/noteEditText"
android:background="#drawable/blueborder"
android:textColorHint="#FFFFFF"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="6dp"
android:paddingTop="10dp" android:paddingBottom="20dp" android:paddingLeft="10dp"
android:layout_weight="3.33"
android:scrollbars="vertical" android:hint="Edit5" android:lines="2" android:textColor="#FFFFFF"
android:gravity="top|center_vertical"/>
<CheckBox
android:text="Check1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/newContactCheckbox"
android:layout_marginLeft="20dp"
android:textColor="#color/apptheme_color"
android:layout_weight="1"
/>
<CheckBox
android:text="Check2"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/isWantedCheckbox" android:layout_marginLeft="20dp"
android:textColor="#color/apptheme_color"
android:layout_weight="1"
/>
<Button
android:text="Send"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/addButton" android:layout_weight="2"
android:textColor="#02485a" android:background="#drawable/blackborder"
android:layout_marginLeft="25dp" android:layout_marginRight="25dp"
android:layout_marginBottom="16dp"/>
<TextView
android:text="Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/notRegisterTextView"
android:textSize="14sp" android:textColor="#color/apptheme_color"
android:layout_marginLeft="25dp" android:padding="7dp"
/>
</LinearLayout>
</ScrollView>
And in Manifest I set android:windowSoftInputMode="stateUnchanged|adjustResize"
How to fix background image with scrollview when windowSoftInputMode appears.
I used windowSoftInputMode="adjustPan",but scrollview doesn't work
completely, please help me. Last fields do not appear when virtual keyboard
appears.
I want that background image should not scroll up with virtual keyboard
and scrollview should show all the fields inside it while scrolling.
Here is my code
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/back">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cancel_done_btn"
android:layout_marginLeft="30dp"
android:layout_marginTop="40dp"
android:textSize="17dp"
android:paddingTop="10dp"
android:textStyle="bold"
android:paddingBottom="10dp"
android:paddingLeft="28dp"
android:paddingRight="28dp"
android:text="#string/cancel"
android:id="#+id/btn_cancel_signin"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cancel_done_btn"
android:layout_marginRight="30dp"
android:layout_marginTop="40dp"
android:textSize="17dp"
android:text="#string/done"
android:paddingTop="10dp"
android:textStyle="bold"
android:paddingBottom="10dp"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:layout_alignParentRight="true"
android:id="#+id/btn_done_signin"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:layout_marginLeft="40dp"
android:orientation="vertical"
android:layout_below="#+id/btn_cancel_signin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="times new roman"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Tuesday,May"
android:textSize="25dp"
android:textStyle="bold"
android:id="#+id/tv_day_month" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="times new roman"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" 7,2016"
android:textSize="25dp"
android:textStyle="bold"
android:id="#+id/tv_date" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="200dp"
android:layout_marginLeft="130dp"
android:layout_below="#+id/btn_cancel_signin">
<ImageView
android:id="#+id/iv_signin_logo"
android:layout_width="200dp"
android:layout_height="180dp"
android:src="#drawable/sign_in_logo"
android:layout_marginTop="10dp" />
</LinearLayout>
<ScrollView
android:layout_width="350dp"
android:layout_height="wrap_content"
android:id="#+id/scroller_sign_in"
android:layout_below="#+id/btn_done_signin"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<LinearLayout
android:orientation="vertical"
android:paddingLeft="10dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp">
<TextView
android:layout_height="wrap_content"
android:text="First Name"
style="#style/sign_in_text"
android:id="#+id/label_firstname"
android:layout_alignParentLeft="true"
android:paddingTop="10dp"
android:inputType="textCapWords"
/>
<AutoCompleteTextView
android:id="#+id/et_firstname"
android:hint="Required"
android:ems="10"
android:textSize="20dp"
android:padding="10dp"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
>
<TextView
android:layout_height="wrap_content"
android:text="Last Name"
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:gravity="left"
android:id="#+id/label_lastname"
android:paddingTop="10dp"
android:layout_alignParentLeft="true"
android:inputType="textCapWords"
/>
<AutoCompleteTextView
android:id="#+id/et_lastname"
android:hint="Required"
android:ems="10"
android:textSize="20dp"
android:textAllCaps="true"
android:padding="10dp"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:inputType="textCapWords"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:id="#+id/ll_company"
>
<TextView
android:layout_height="wrap_content"
android:text="Company"
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:gravity="left"
android:layout_marginTop="10dp"
android:id="#+id/label_company"
android:layout_alignParentLeft="true"
/>
<AutoCompleteTextView
android:id="#+id/et_company"
android:ems="10"
android:textSize="20dp"
android:padding="10dp"
android:textAllCaps="true"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<!--android:background="#drawable/contact_edittext_bg"-->
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:id="#+id/ll_address"
>
<TextView
android:layout_height="wrap_content"
android:text="Address"
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:gravity="left"
android:id="#+id/label_address"
android:paddingTop="15dp"
/>
<AutoCompleteTextView
android:id="#+id/et_address"
android:ems="10"
android:textSize="20dp"
android:padding="10dp"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:id="#+id/ll_city"
>
<TextView
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:gravity="left"
android:layout_height="wrap_content"
android:text="City"
android:id="#+id/label_city"
android:paddingTop="15dp"
/>
<AutoCompleteTextView
android:id="#+id/et_city"
android:ems="10"
android:textSize="20dp"
android:padding="10dp"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:inputType="textCapWords"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:id="#+id/ll_state"
>
<AutoCompleteTextView
android:id="#+id/et_state"
android:ems="10"
android:textSize="20dp"
android:padding="10dp"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:inputType="textCapWords"/>
<TextView
android:layout_height="wrap_content"
android:text="State"
style="#style/sign_in_text"
android:id="#+id/label_state"
android:paddingTop="15dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:id="#+id/ll_zip_code"
>
<TextView
android:layout_height="wrap_content"
android:text="Zip Code"
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:gravity="left"
android:id="#+id/label_zip_code"
android:paddingTop="15dp"
/>
<AutoCompleteTextView
android:id="#+id/et_zipcode"
android:ems="10"
android:layout_width="160dp"
android:background="#drawable/et_border"
android:textSize="20dp"
android:padding="10dp"
android:layout_height="wrap_content"
android:inputType="number"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
remove this from xml.
android:background="#drawable/back"
Write in your java file.
getWindow().setBackgroundDrawableResource(R.drawable.back);
I just put a linear layout inside a scrollview dont know why its not working.
When the keyboard is open the scrollbar is not showing at all. When i move one text box to another there is a submit button which is not show when i run on small size devices.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/layoutPopUp"
android:layout_width="match_parent"
android:layout_height="79dp"
android:background="#F57F20"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:visibility="visible">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/backlayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal">
<ImageButton
android:id="#+id/btnBackbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/back"
android:visibility="visible" />
<TextView
android:id="#+id/textBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:gravity="center"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/textTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.6"
android:gravity="center"
android:text="Contact Us"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imagePopUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/menu"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Phone No."
android:inputType="phone"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:hint="Comments"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</LinearLayout>
try to put scrollview inside another linear layout and try
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/parentLin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="//define in dp"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColorHint="#2b2b2b"
android:textColor="#2b2b2b"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:textColor="#2b2b2b"
android:hint="Phone No."
android:inputType="phone"
android:textColorHint="#2b2b2b"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColor="#2b2b2b"
android:ems="10"
android:textColorHint="#2b2b2b"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:textColor="#2b2b2b"
android:hint="Comments"
android:textColorHint="#2b2b2b"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
and You have to specify the following line of code in the manifest file with your activity
android:windowSoftInputMode="adjustResize"
try This.. on your activity / fragment
getActivity().getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
In my application i am using recycler view and scrollview in one layout. it is not working when i am using both these views. If i remove scroll view only the recycler view is working. Plese any one help me hoe to fix this issue.
my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/r1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
>
<ScrollView
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1e356a">
<TextView
android:id="#+id/placce_head"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Hyderabad to banglore"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Selected Seats"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/totalamount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Total Amount"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seat_num"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/total_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/boardingpoint_edttxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint=" Select Boarding Point"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/contact_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Contact Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<EditText
android:id="#+id/contactname_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Name"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/email_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Email Address"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/contactnum_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/emergency_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Emergency Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/passenger_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Passenger Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/view"
android:layout_below="#+id/sc"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<LinearLayout
android:id="#+id/coupon_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="8dp"
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="100" >
<EditText
android:id="#+id/entercouponcode_edt"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="50"
android:hint="Enter coupn code"
android:inputType="text" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bt_apply"
style="#style/payment_button_style"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="-5dp"
android:layout_weight="40"
android:gravity="center"
android:text="Apply" />
</LinearLayout>
<Button
android:id="#+id/pay_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#F93249"
android:duplicateParentState="true"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Proceed to Pay"
android:textColor="#ffffff"
android:textSize="20dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
you must know that ,your scrollview property is set as MatchParent ,which means it will fill the content view, so i suggest to set Height a real value such as 100dp, and it will work
You need to dynamically change the height of the recyclerview, depending on how many items you have.
int recyclerheight = height_per_item * adapterData.size();
recyclerView.getLayoutParams().height = recyclerheight;
The scroll view blocks the recyclerview from changing its height set in the xml, that's why you need to do it programically.