Android soft keyboard covers Edittext android - android

Android: show soft keyboard automatically covers half of Edittext field after clicking on that particular Edittext implemented in the bottom of the layout. When request focus on EditText soft keyboard opens and it will shift the layout upward but covers up the half of Edittext field.
<?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"
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="0.12"
android:background="#color/green"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/ll_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#drawable/btn_selector"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_back"
android:focusableInTouchMode="true" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_circle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/btn_selector"
android:gravity="center_vertical|start"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circleView"
android:layout_width="#dimen/list_circle"
android:layout_height="#dimen/list_circle"
android:layout_gravity="center"
android:layout_margin="7dp"
android:src="#drawable/logo8" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_id"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:background="#drawable/btn_selector"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\#gaurav.yadav"
android:textColor="#android:color/white"/>
<TextView
android:id="#+id/textView81"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1d" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"></LinearLayout>
<LinearLayout
android:id="#+id/ll_p"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center_vertical|right"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_post"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/btn_selector"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.87"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerView_topcollege"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.12"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/ll_attachment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:drawable/ic_menu_gallery" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:background="#drawable/bg_edittext"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:background="#00000000"
android:hint="Write a Answer...."
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#android:drawable/ic_menu_send"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView27"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

set flag in the manifest as,
android:windowSoftInputMode="stateHidden|adjustPan"

Put your required code in scrollview, than for activity class you have to set one property
android:windowSoftInputMode="adjustResize"

set focus to dummy layout or any view in your xml
like
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:orientation="vertical" >

Related

How to set on click listener for view under of list view

I have a listview with header that its header is transparent, under of its header there is a view that I want to click on it before listview items get up to that by scrolling.
I search some solutions like : use cancelable or focusable property of header and set those values to false; But the problem still is alive!
How can access to onclick listener of view that's under another view in this special situation?
I want to click on orderTypeLinearLayout
<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="#color/lightestGray"
android:orientation="vertical">
<LinearLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/gray"
android:orientation="vertical">
<LinearLayout
android:id="#+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:background="#color/gray"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="#+id/titleImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="centerInside"
tools:ignore="ContentDescription,NestedWeights" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/orderTypeLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_arrow_drop_down_white"
tools:ignore="ContentDescription,RtlHardcoded" />
<TextView
android:id="#+id/orderTypeTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="left"
android:textColor="#color/white"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<TextView
android:id="#+id/userListTitleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="right"
android:textColor="#color/white"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:background="#color/gray" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/scoreBoardSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/scoreBoardFragmentListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:divider="#null" />
</android.support.v4.widget.SwipeRefreshLayout>

Android, layout_above not working

I want to display some text in the middle of the screen, below header and above footer. Since this text is very long I nested it in ScrollView. I have tried a number of solutions: this, this, this, this, and a bunch more...
At first I had a problem of the two relative_layouts overlapping and text being cut of. The most accepted answer is to use layout_above and layout_below, but when I use layout_above, the text is never displayed.
This is what my xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/gray"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/profile_photo"
android:src="#drawable/default_profile"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/text"/>-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:background="#color/gray"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/red" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/white"
android:layout_weight="1"
android:gravity="center"
android:text="#string/blue" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:textColor="#color/white"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/green" />
</LinearLayout>
</RelativeLayout>
in your ln_layout_footer
set android:layout_height="wrap_content"
Edited
<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:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray_pressed"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/action_settings"
android:src="#drawable/img_splash_logo"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/txt_price" />-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_quantity"
android:textColor="#color/white" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_material"
android:textColor="#color/white" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/msg_enter_user_name"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
In you layout using two properties that why it doesn't work. So you can remove one properties here is your working code
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp">
<TextView
android:textColor="#000"
android:id="#+id/meetupDescription"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:text="#string/text" />-
</ScrollView>
</RelativeLayout>
you can use this android:layout_below="#+id/linear_layout_header or this android:layout_above="#+id/ln_layout_footer, one property at a time. or simply copy and past

2 Views side by side with the same height

I'm using 2 inner Linearlayouts to divide my screen into 2 sections. It looks like this:
The first inner Layout has a TextView and a Button. The second one has a ImageView and also a Button. Now I want to get the same height for the TextView and ImageView without setting a fix value for layout_height. The left button should also be in line with the right button.
Here is my xml:
<LinearLayout 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:orientation="horizontal"
tools:context="de.dk.masterfi.ActMain">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="280dp"
android:background="#drawable/border"
android:padding="10dp"
android:text="#string/welcome"/>
<Button android:id="#+id/button2" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Favoriten"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="280dp" android:src="#drawable/training"/>
<Button android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="Hauptmenü"/>
</LinearLayout>
try this, note the android:layout_weight="1" attribute for TextView and ImageView:
<LinearLayout
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:orientation="horizontal"
tools:context="de.dk.masterfi.ActMain">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/border"
android:padding="10dp"
android:text="#string/welcome"/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Favoriten"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#drawable/training"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hauptmenü"/>
</LinearLayout>
</LinearLayout>
Try this:
android:layout_height = "0dp"
android:layout_weight = "1.0"
Change the weight according to your specs
Change your xml to
<LinearLayout
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:orientation="horizontal"
tools:context="de.dk.masterfi.ActMain">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/border"
android:padding="10dp"
android:text="#string/welcome"/>
<Button android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Favoriten"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="#drawable/training"
android:layout_weight="1"/>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hauptmenü"/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_trail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
tools:context="com.nividbharat.educompanion.activities.TrailActivity">
<RelativeLayout
android:id="#+id/relLayout1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:layout_weight="0.5"
android:background="#android:color/black"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/button1"
android:background="#android:color/holo_red_dark" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button1" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relLayout2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:layout_weight="0.5"
android:background="#android:color/black">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/button2"
android:background="#android:color/holo_red_dark" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button2" />
</RelativeLayout>
</LinearLayout>
This is how the preview of the layout look like,

trying to position my checkbox above the keyboard in XML

My activity looks like this:
I use this XML :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7">
</SearchView>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:src="#drawable/settingsicon"
android:background="#drawable/ambuttonstatessettings"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contacts_list"></ListView>
</LinearLayout>
But I want it to look like this, with a checkbox above the keyboard. Or if the keyboard is not there, the checkbox should be at the bottom :
Any idea how I can do this ? I tried this code, which is the closest I've come (basically, making a new linear layout at the bottom) but I can't get it right. And can't figure out why.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7">
</SearchView>
<!--android:drawableLeft="#android:drawable/ic_menu_search"-->
<!--android:queryHint="howdy"-->
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:src="#drawable/settingsicon"
android:background="#drawable/ambuttonstatessettings"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contacts_list"></ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
try this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7"/>
<!--android:drawableLeft="#android:drawable/ic_menu_search"-->
<!--android:queryHint="howdy"-->
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:background="#787878"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:id="#+id/contacts_list"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="20"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
this is the solution.

Scrollview inside viewpager scroll vertical not working

Below is my code but its not working properly, want a viewpager with scrollview in all fragment. Scrolling of the scrollview is not working,facing problem from last 2 hrs and not getting a solution.Please help me its urgent.Not able to solve this issue i tried adding nested scrollview but it is also not working.
<?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:orientation="vertical">
<LinearLayout
android:id="#+id/toolbar_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_myjeenees"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/white"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="#+id/toolbarShuffle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Shuffle Money"
android:textColor="#color/black"
android:textSize="18sp" />
</android.support.v7.widget.Toolbar>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="UserName"
android:textSize="25sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="May 15,Birthday" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:background="#mipmap/ic_forward" />
</LinearLayout>
<com.android.jeenees.utils.CustomScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
>
<android.support.v4.view.ViewPager
android:id="#+id/shufflePager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white" />
</com.android.jeenees.utils.CustomScrollView>
<!--</LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:padding="10dp"
android:src="#mipmap/ic_action_tick" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:padding="10dp"
android:src="#mipmap/ic_back" />
</LinearLayout>
<?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:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/firstwish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IPhone 5s" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/costfirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs 5300/32777" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<SeekBar
android:id="#+id/seekfirst"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:maxHeight="10dp"
android:progress="50"
android:progressDrawable="#drawable/progress_draw"
android:splitTrack="false"
android:thumb="#mipmap/ic_thumb"></SeekBar>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/secondwish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IPhone 5s" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/costsecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs 5300/32777" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<SeekBar
android:id="#+id/seeksecond"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:maxHeight="10dp"
android:progress="50"
android:progressDrawable="#drawable/progress_draw"
android:splitTrack="false"
android:thumb="#mipmap/ic_thumb"></SeekBar>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/thirdwish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IPhone 5s" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/costthird"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs 5300/32777" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<SeekBar
android:id="#+id/seekthird"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:maxHeight="10dp"
android:progress="50"
android:progressDrawable="#drawable/progress_draw_red"
android:splitTrack="false"
android:thumb="#mipmap/ic_red_thumb"></SeekBar>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Rs 1700"
android:textSize="25sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Released Money"
android:textSize="25sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:drawableLeft="#mipmap/ic_actin_add"
android:gravity="center"
android:padding="15dp"
android:text="Top Up"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Each view take parent event first if your view pager is swipe horizonatly for change the page tab than you can not use horizonatl scroll in child fragment . It is not write practice you can arrange your page content as vertical and use vertical scroll view.
Or second option you will have to disable swipe event for view pager and only tab click is uesd to change page than you can use horizontal scroll view.

Categories

Resources