I have problems with word cutting at XML, look at the picture below:
As you can see word Delete is cut. Below is my layout for this part:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal"
android:weightSum="30"
android:baselineAligned="false">
<RelativeLayout
android:id="#+id/more_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#color/gray_light"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_more"
android:drawablePadding="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_below="#id/pict_1"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/archive"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="10"
android:background="#color/colorAccent"
android:paddingStart="5dp"
android:paddingEnd="5dp">
<ImageView
android:id="#+id/pict_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_inbox"
android:contentDescription="TODO" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Archive"
android:layout_below="#id/pict_2"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#FF0000"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_delete"
android:drawablePadding="10dp" />
<TextView
android:layout_below="#id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:textAlignment="viewStart"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
In general I noticed that it is caused by padding which pull elements inside parent layout. I tried to change it, but I see that word Archive is also can be influenced. How I can solve this problem with wrong layout xml?
add you third layout(delete) with wrap content and weight like below
<RelativeLayout
android:id="#+id/delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#FF0000"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_delete"
android:drawablePadding="10dp" />
<TextView
android:layout_below="#id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:textAlignment="viewStart"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
Related
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 have my views in a scroll view so that if the content is bigger than the screen size, the user can scroll down. I have noticed a weird thing.
The first time the content comes up, it doesn't scroll. However, when the user changes a setting and the content of the views which are inside the scroll view reloads it does become scrollable.
Why is this? Is it clear what I mean?
EDIT: This only happens on my Nexus 5X. But when I used a Samsung J10 it works right away.
My XML is a relative layout, with a child element of the scroll view, which contains other views.
Here is my 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:id="#+id/content_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.apps.reuven.egertandcohentravel.Activities.HomeActivity"
tools:showIn="#layout/activity_home">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="50dp"
android:id="#+id/progressBar"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:visibility="gone"
/>
<TextView
android:id="#+id/textViewLinkToOrder"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here to book travel insurance."
android:textColor="#color/colorPrimary"
android:layout_centerHorizontal="true"
android:textSize="24sp"
android:gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttons_linear_layout"
android:orientation="horizontal"
android:layout_below="#id/textViewLinkToOrder">
<Button
android:layout_width="200dp"
android:id="#+id/choose_country_button"
android:onClick="onChooseCountryButtonClick"
android:layout_height="wrap_content"
android:text="Choose country"
android:layout_marginLeft="5dp"
android:background="#color/colorPrimary"
android:layout_weight="1"
android:textColor="#ffff"
android:layout_marginRight="5dp"
android:layout_below="#id/textViewLinkToOrder"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="200dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:textColor="#fff"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:id="#+id/automatic_country_button"
android:layout_height="wrap_content"
android:text="My Location"
android:layout_below="#id/choose_country_button"
android:layout_centerHorizontal="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayoutAllDetails"
android:layout_below="#id/buttons_linear_layout"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No country yet selected"
android:gravity="center"
android:id="#+id/textView_coumtry_name"
android:textColor="#000000"
android:textSize="30sp"
android:padding="5dp"
android:textStyle="bold"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/police"/>
<TextView
android:textSize="17sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Police"
android:textColor="#000000"
android:layout_gravity="center_vertical" />
<TextView
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/police_text_view"
android:text=""
android:textColor="#000000"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<ImageView
android:id="#+id/police_phone_button"
android:layout_width="30dp"
android:layout_gravity="center_vertical"
android:layout_height="30dp"
android:src="#android:drawable/sym_action_call"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/ambulance"/>
<TextView
android:textSize="17sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ambulance"
android:textColor="#000000"
android:layout_gravity="center_vertical" />
<TextView
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ambulance_text_view"
android:text=""
android:textColor="#000000"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<ImageView
android:layout_width="30dp"
android:layout_gravity="center_vertical"
android:layout_height="30dp"
android:src="#android:drawable/sym_action_call"
android:id="#+id/ambulance_phone_button"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/israel_consulate"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textSize="17sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Israel Consulate"
android:textColor="#000000"
android:layout_gravity="center_vertical" />
<TextView
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/israel_consulate_text_view"
android:text=""
android:textColor="#000000"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<ImageView
android:layout_width="30dp"
android:layout_gravity="center_vertical"
android:layout_height="30dp"
android:src="#android:drawable/sym_action_call"
android:id="#+id/israel_phone_button"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/chabad"/>
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textSize="17sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beit Chabad"
android:textColor="#000000"
android:layout_gravity="center_vertical" />
<TextView
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/chabad_address_text_view"
android:text="3 Blue Street, USA"
android:textColor="#000000"
android:layout_gravity="center_vertical"/>
<TextView
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/chabad_number_text_view"
android:text="+44 456 3245234"
android:textColor="#000000"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<ImageView
android:layout_width="30dp"
android:layout_gravity="center_vertical"
android:layout_height="30dp"
android:src="#android:drawable/sym_action_call"
android:id="#+id/chabad_phone_button"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Thanks very much, I can't figure this one out.
I also had the same problem and by adding a TableLayout inside ScrollView solved the problem for me. Then, add your content (RelativeLayout) inside TableLayout.
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<-- Your RelativeLayout goes here -->
</TableLayout>
</ScrollView>
Let me know if that solved the problem. Do not forget to add the attribute fillViewport=true to ScrollView so the TableLayout match it's parent's view width and height.
This is my XML file for presenting the Layout.
edit_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_bg">
<LinearLayout
android:id="#+id/ll_userregisteration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="30dp"
android:isScrollContainer="true"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<com.shout.networking.view.RoundedImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="center"
android:src="#drawable/profile_placeholder"/>
<ImageButton
android:id="#+id/camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What do we call you"
android:textColor="#color/white"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_reg_Fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:textSize="16sp"
android:layout_weight="1"
android:backgroundTint="#color/white"
android:hint="first name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_reg_Lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:textSize="16sp"
android:backgroundTint="#color/white"
android:hint="last name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
</LinearLayout>
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rb_male"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="true"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Male"
android:textColor="#android:color/white"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_female"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="false"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Female"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="School of your cool"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_university"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:textSize="14sp"
android:hint="add your university"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="what you call home"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_livingaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you live now"
android:textColor="#color/white"
android:textSize="16sp"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_permanentaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you belong to"
android:textSize="16sp"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Whats Your Calling"
android:textColor="#color/white"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_interset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:layout_toLeftOf="#+id/sp_interset"
android:hint="Type in your calling/pick from the list"
android:textSize="16sp"
android:maxLength="30"
android:textColor="#color/white"
android:textColorHint="#7c7875"
android:maxLines="1" />
<Spinner
android:id="#+id/sp_interset"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:background="#drawable/down_thicker"
android:dropDownWidth="250dp"
android:backgroundTint="#android:color/white"
android:popupBackground="#4b4b49"
android:spinnerMode="dropdown" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginTop="10dp">
<Button
android:id="#+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="CANCEL"
android:layout_marginRight="20dp"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
<Button
android:id="#+id/btn_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="SAVE"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
This is the screenshot for my Layout.I am not able to scroll it.
I have put my Linear LAyout in the ScrollView but then also i am unable to get the scroll functionality in my xml design .
make changes in LinearLayout height to match_parent. it will work.
In ScrollView try adding this line:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
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>
How do i place a line between two linearlayouts horizontally? I tried with a additional linearlayout and a one time with a View. My linearlayouts looks currently like this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
>
<LinearLayout
android:id="#+id/about"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:gravity="start"
android:layout_gravity="start"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
>
<ImageView
android:id="#+id/about_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginStart="20dp"
android:layout_gravity="start|center_vertical"
android:src="#drawable/ic_info_black_24dp"
android:clickable="false"
/>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_gravity="start|center_vertical"
android:text="About"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
<!--<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_weight="2"
android:elevation="0dp"
android:background="#android:color/black"
/>-->
<LinearLayout
android:id="#+id/theme"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="3"
android:gravity="end"
android:layout_gravity="end"
android:background="?android:attr/selectableItemBackground"
>
<ImageView
android:id="#+id/theme_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginEnd="10dp"
android:layout_gravity="end|center_vertical"
android:src="#drawable/ic_palette_white_24dp"
android:tint="#android:color/black"
android:clickable="false"
/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="20dp"
android:text="Theme"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
</LinearLayout>
It looks currently like this(the layout on the right side, is a bit more left, dont understand why ^^):
Any suggestions?
Why not use a RelativeLayout and avoid weights all together. Try this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<View
android:id="#+id/divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:elevation="0dp"
android:background="#android:color/black" />
<LinearLayout
android:id="#+id/about"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:layout_toLeftOf="#id/divider"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="#+id/about_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginStart="20dp"
android:layout_gravity="start|center_vertical"
android:src="#drawable/ic_launcher"
android:clickable="false"
/>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_gravity="start|center_vertical"
android:text="About"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/theme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:layout_toRightOf="#id/divider"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="#+id/theme_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginEnd="10dp"
android:layout_gravity="end|center_vertical"
android:src="#drawable/ic_launcher"
android:tint="#android:color/black"
android:clickable="false"
/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="20dp"
android:text="Theme"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
Get rid of the weights and use a Relative layout to hold your linear layouts. Then add this in your XML:
<View android:id="#+id/separator"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"/>
Then in the layout you want to the right add this line:
android:layout_toRightOf="#+id/separator"
And then for the layout to the left:
android:layout_toLeftOf="#+id/separator"