I am using fragment to display registration page
I want "OTP" button stick to the bottom, so I used relative layout for that. I am using linear layout for edittext. When i click on edittext, keyboard appeared but when I am trying to scroll the page when keyboard is opened, its not scrolling at all
Someone please Help
Here is my fragment 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:background="#F4F4F4"
tools:context="values.Registration">
<ScrollView
android:fillViewport="true"
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F4F4F4"
android:orientation="vertical">
<ImageView
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#fff"
android:orientation="horizontal">
<TextView
android:layout_width="130dp"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="Mobile No. /\nमो. नंबर "
android:textSize="17dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:hint="Mobile NO."
android:maxLength="10"
android:paddingLeft="15dp"
android:paddingStart="5dp"
android:phoneNumber="true"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#fff"
android:textSize="17dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#fff"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="130dp"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="Mail Id. /\nइ-मेल "
android:textSize="17dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:hint="Mobile NO."
android:paddingLeft="15dp"
android:paddingStart="5dp"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#fff"
android:textSize="17dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:layout_marginTop="2dp"
android:background="#fff"
android:orientation="horizontal">
<TextView
android:layout_width="130dp"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="Name /\nनाव"
android:textSize="17dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:hint="Mobile NO."
android:paddingLeft="15dp"
android:paddingStart="5dp"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#fff"
android:textSize="17dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/bt_send_otp"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/colorPrimary"
android:drawablePadding="-40dp"
android:drawableRight="#drawable/arrow_right"
android:paddingRight="15dp"
android:text="SEND OTP / वो. टि. पी. पाठवा"
android:textColor="#FFF"
android:textSize="16dp" />
</RelativeLayout>
in Manifest:
android:windowSoftInputMode="adjustResize"
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 am not able to find out the exact issue that why the image(background) is not visible in API level 16 but it is showing good in API level 19. I have worked simply as i have done previously but , this time the background is not shown(of WaterMark in ImageView).
I am not able to find out what is exact issue . So i need help.I have done every thing as suggested in the stack Android device is not showing the background image but it is not going good in my case.
xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlGetInTouch"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#304EA2">
<RelativeLayout
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_bg2">
<ImageView
android:id="#+id/brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/nbl_logo4" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#304EA2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="35dp"
android:layout_marginTop="-60dp"
android:color="#android:color/transparent"
android:src="#drawable/logowatermark" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/edit_text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="35dp"
android:paddingRight="35dp">
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text=" Please login to proceed"
android:textColor="#color/white"
android:textSize="12sp"
android:textStyle="normal" />
<******.CustomFontEditText
android:id="#+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="#drawable/edit_text_border"
android:drawablePadding="8dp"
android:gravity="center"
android:hint="Mobile Number"
android:inputType="number"
android:maxLength="#integer/mobile_length"
android:padding="13dp"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="12dp"
android:textStyle="bold" />
<******.CustomFontEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_toLeftOf="#+id/passwordVisibilityBtn"
android:background="#drawable/edit_text_border"
android:drawablePadding="8dp"
android:gravity="center"
android:hint="Password"
android:inputType="textPassword"
android:maxLength="#integer/password_length"
android:padding="13dp"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="12dp"
android:textStyle="bold" />
<******.CustomFontCheckBox
android:id="#+id/chkSaveUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:button="#drawable/custom_checkbox"
android:drawablePadding="5dp"
android:gravity="center"
android:text=" Remember Mobile No."
android:textColor="#color/white"
android:textSize="12sp"
android:textStyle="normal" />
<LinearLayout
android:id="#+id/loginLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/login_button_shadow"
android:orientation="vertical">
<******.CustomFontLoginTextView
android:id="#+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/login_button_new1"
android:clickable="true"
android:gravity="center"
android:padding="13dp"
android:text="Login"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="14sp" />
<******.CustomFontLoginTextView
android:id="#+id/action_sms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/login_button_new1"
android:clickable="true"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:text="Switch To SMS"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<******.CustomFontLoginTextView
android:id="#+id/resetDeviceId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:alpha="0.7"
android:drawableLeft="#drawable/icon_reset_20"
android:drawablePadding="3dp"
android:gravity="center"
android:text="#string/reset_device_id_text"
android:textColor="#color/white"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:id="#+id/action_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:alpha="0.7"
android:drawableLeft="#drawable/icon_info_20"
android:drawablePadding="3dp"
android:gravity="center"
android:text="#string/info"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- Promo -->
<LinearLayout
android:id="#+id/llPromotions"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/promo_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBranches"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlLogin"
android:layout_gravity="center"
android:background="#304EA2"
android:gravity="center"
android:orientation="horizontal"
android:padding="15dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="showATMs"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:padding="2dp"
android:src="#drawable/icon_atm_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="ATM"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Locate nearest Atm Machines"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="showBranches"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:src="#drawable/ic_branches_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="8dp"
android:text="BRANCHES"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Locate nearest bank branches"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:onClick="showRates"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:src="#drawable/ic_rates_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="RATES"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Foreign exchange and stock rates"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/rlProducts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="vertical">
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Products"
android:textAllCaps="true"
android:textColor="#color/gray"
android:textSize="14sp" />
<!--Product Container-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--Product 1-->
<LinearLayout
android:id="#+id/product_content1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="7.5dp"
android:layout_weight="1"
android:orientation="vertical" />
<!--Product 2-->
<LinearLayout
android:id="#+id/product_content2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="7.5dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:gravity="end"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/rlGetInTouch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#304EA2"
android:orientation="horizontal">
<CustomFontLoginTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/btnCall"
android:paddingLeft="15dp"
android:singleLine="true"
android:text="Get in touch with us"
android:textColor="#color/white"
android:textSize="16sp"
android:textStyle="normal" />
<!--app:maxTextSize="14sp"
app:minTextSize="#dimen/minFontSize"-->
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnMap"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:onClick="showLocation"
android:src="#drawable/ic_action_location_24_4" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnEmail"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btnMap"
android:layout_toStartOf="#+id/btnMap"
android:onClick="openEmail"
android:src="#drawable/ic_action_mail_24_4" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnCall"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btnEmail"
android:layout_toStartOf="#+id/btnEmail"
android:onClick="openCall"
android:src="#drawable/ic_action_call_24_4" />
</RelativeLayout>
</RelativeLayout>
The Image background of watermark is not shown. I have done nothing
new ,same as previous but dont' know that is the exact issue.
Please reduce image size to visible in the lower level device.
I Just Removed marginTop and it worked fine in API level 16
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="35dp"
android:src="#drawable/logowatermark" />
I don't understand that why it worked when i remove the -ve marginTop
in above? .I got solution but don't understand what exactly happened
in adding -ve marginTop and with removing -ve marginTop.
I know it is silly question but i used many solution which already given by stack Overflow but no one solve my problem, my question is, I want to Scroll Up the layout after clicking on last edittext because keyboard hide the EditText and i am unable to see what is typing..
Code I am using in onCreate method
scrollView=(ScrollView)findViewById(R.id.activityRoot);
addressEdt=(EditText)findViewById(R.id.profilAddress);
addressEdt.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
scrollView.fullScroll(ScrollView.FOCUS_UP);
}
});
My xml code is
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="#+id/activityRoot">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/colorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginTop="10dp"
android:id="#+id/linearLayout7">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/driverName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|bottom"
android:layout_marginTop="90dp"
android:gravity="center"
android:padding="5dp"
android:text="Kevin Michaels"
android:textSize="18dp" />
<TextView
android:id="#+id/total_rides_editProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|bottom"
android:layout_marginTop="140dp"
android:gravity="center"
android:padding="5dp"
android:text=""
android:textSize="17dp" />
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/userProfileImageView"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal|top"
android:scaleType="centerCrop"
android:src="#drawable/profile_user_icon" />
<ProgressBar
android:id="#+id/profileImageProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="30dp" />
<ImageView
android:id="#+id/userChangePhotoButton"
android:layout_width="37dp"
android:layout_height="37dp"
android:layout_gravity="right|top"
android:src="#drawable/camera_icon" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_below="#+id/linearLayout7">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:hint="Username"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:maxLength="20"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
style="#style/ProfileUserNameEditText"
android:singleLine="true"
android:id="#+id/txtprofileUserName"/>
<EditText
style="#style/ProfileMobileNumberEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profileMobile"
android:layout_gravity="center_horizontal"
android:hint="Mobile"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:maxLength="10"
android:singleLine="true"
android:inputType="phone|textPhonetic"/>
<EditText
style="#style/ProfileAddressEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profilAddress"
android:layout_gravity="center_horizontal"
android:hint="Address"
android:inputType="text"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:singleLine="true"
android:maxLines="1"
android:drawableLeft="#drawable/edit_profile_address"
android:maxLength="40"
/>
<TextView
style="#style/ProfileEmailEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profileEmail"
android:layout_gravity="center_horizontal"
android:hint="Email"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:singleLine="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/saveProfileButton"
android:background="#drawable/a_log_in_button"
android:text="Done"
android:textColor="#color/white"
android:layout_marginTop="10dp"
android:textSize="17dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
I am using a RecyclerView with CardViews inside and I want to remove the Margins/Padding/Spacing left in between the children cards inside the RecyclerView. How can I do that?
Here is my CardView:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<!--status lock-->
<ImageView
android:id="#+id/imageField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="20dp" />
<!--text info section-->
<LinearLayout
android:id="#+id/textInfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<!--NAME-->
<TextView
android:id="#+id/nameField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="item name"
android:gravity="center_vertical"
android:textSize="#dimen/abc_text_size_large_material" />
<!--category-->
<TextView
android:id="#+id/categoryField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:text="category"
android:textSize="#dimen/abc_text_size_small_material" />
<!--working hours-->
<LinearLayout
android:id="#+id/workingHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/workingHoursIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="#drawable/ic_clock"
android:padding="50dp"></ImageView>
<TextView
android:id="#+id/WHStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp" />
<TextView
android:id="#+id/dash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" - " />
<TextView
android:id="#+id/WHEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:paddingLeft="5dp" />
</LinearLayout>
<!--message-->
<LinearLayout
android:id="#+id/messageSection"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/messageIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="#drawable/ic_message"
android:padding="50dp" />
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:paddingLeft="5dp"
android:text="No Message" />
</LinearLayout>
</LinearLayout>
<!--add to favorite button-->
<ImageButton
android:id="#+id/btn_add_to_favorite_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="20dp"
android:layout_marginStart="48dp"
android:background="#drawable/ic_star_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
And my RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/my_store"
android:scrollbars="vertical" />
Here is a screenshot:
This might be what you were looking for CardView inside RecyclerView has extra margins
Plus if you are not looking to keep spaces you should simply use a LinearLayout for your adapter layout removing the CardView altogether, that should do it.
Hope that helps.
Check if it is margin or padding (Dev Options / show layout bounds)
CardView adds padding in pre-L API levels to show shadows. In L, unless you set useCompatPadding=true, there should not be any gap.
Adding negative margins (although it is ugly) should work.
This might work
card_view:contentPaddingLeft="-3dp"
card_view:contentPaddingRight="-3dp"
card_view:contentPaddingTop="-3dp"
card_view:contentPaddingBottom="-3dp"
Try this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<!--status lock-->
<ImageView
android:id="#+id/imageField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="20dp" />
<!--text info section-->
<LinearLayout
android:id="#+id/textInfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<!--NAME-->
<TextView
android:id="#+id/nameField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="item name"
android:gravity="center_vertical"
android:textSize="#dimen/abc_text_size_large_material" />
<!--category-->
<TextView
android:id="#+id/categoryField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:text="category"
android:textSize="#dimen/abc_text_size_small_material" />
<!--working hours-->
<LinearLayout
android:id="#+id/workingHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/workingHoursIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="#drawable/ic_clock"
android:padding="50dp"></ImageView>
<TextView
android:id="#+id/WHStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp" />
<TextView
android:id="#+id/dash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" - " />
<TextView
android:id="#+id/WHEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:paddingLeft="5dp" />
</LinearLayout>
<!--message-->
<LinearLayout
android:id="#+id/messageSection"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/messageIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="#drawable/ic_message"
android:padding="50dp" />
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:paddingLeft="5dp"
android:text="No Message" />
</LinearLayout>
</LinearLayout>
<!--add to favorite button-->
<ImageButton
android:id="#+id/btn_add_to_favorite_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="20dp"
android:layout_marginStart="48dp"
android:background="#drawable/ic_star_gray" />
</LinearLayout>
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.