I need your help!
I have an activity which supposed to be scrollable,
Therefore the ScrollView is the top layout(i hope this is how you call it).
I used android:fillViewport="true" on the ScrollView
-The ScrollView's child is a LinearLayout with a couple of more nested LinearLayouts.
Now my problem is that on the preview screen(Design) i see my layout fine
but when i run the app on an Emulator,i only see half of my layout (until the first nested LinearLayout) and as a collateral damage, the scrollview isn't scrollable.
Thanks in advance for the help!
Design Screen Image:
[At the preview screen it looks good]
Emulator Screen Image:
[As you can see ,only half of the scrollview's content is showing ]
Updated layout file:(still showing only half of the layout at runtime)
Added:
- tools:context=
- ScrollView changed from layout_height="wrap_content" to
layout_height="match_parent"
Removed all instances of weight="1" from all nested LinearLayouts.
AddParkingActivity.xml:
xml version="1.0" encoding="utf-8"
<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFA3D2E9"
android:clickable="true"
android:clipToPadding="false"
android:fillViewport="true"
android:focusable="true"
android:layoutDirection="rtl">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:orientation="vertical"
android:textDirection="rtl">
<TextView
android:id="#+id/addParkingActivity_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="23dp"
android:fontFamily="cursive"
android:text="הוספת חנייה חדשה למסד הנתונים"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="24sp"
android:textStyle="bold"
android:typeface="monospace" />
<EditText
android:id="#+id/addParkingActivity_Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="שם החניון"
android:inputType="textPersonName"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<EditText
android:id="#+id/addParkingActivity_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="אזור מפורט"
android:inputType="textPersonName"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<Spinner
android:id="#+id/addParkingActivity_subAreaSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#FF909090" />
<LinearLayout
android:id="#+id/ll_radioG1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<RadioButton
android:id="#+id/addParkingActivity_crewAcc_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/radioLeft"
android:text="לינה לצוות"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_water_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:text="מים"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_showers_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:text="מקלחות"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_accessibility_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:text="נגישות"
android:textColor="#000"
android:textDirection="rtl" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#FF909090" />
<LinearLayout
android:id="#+id/ll_radioG2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<RadioButton
android:id="#+id/addParkingActivity_fence_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="#dimen/radioLeft"
android:text="גדר"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_toilets_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:text="שירותים"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_cookingPos_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:text="עמדות בישול"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_equipmentToBor_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:text="ציוד להשאלה"
android:textColor="#000"
android:textDirection="rtl" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#FF909090" />
<LinearLayout
android:id="#+id/ll_radioG3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<RadioButton
android:id="#+id/addParkingActivity_electricity_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="#dimen/radioLeft"
android:text="חשמל ותאורה"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_securityServ_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:text="שירותי אבטחה"
android:textColor="#000"
android:textDirection="rtl" />
<RadioButton
android:id="#+id/addParkingActivity_medicalServ_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:text="שירותי רפואה"
android:textColor="#000"
android:textDirection="rtl" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#FF909090" />
<LinearLayout
android:id="#+id/ll_radioG5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<Button
android:id="#+id/addParkingActivity_buttonMarkAll"
android:layout_width="49dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:background="#drawable/roundedbutton"
android:onClick="onMarkAllClick"
android:text="סמן הכל" />
<Button
android:id="#+id/addParkingActivity_buttonUNMarkAll"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:background="#drawable/roundedbutton"
android:onClick="onUNMarkAllClick"
android:text="אפס כפתורים" />
</LinearLayout>
<EditText
android:id="#+id/addParkingActivity_securityOrganization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="#string/securityOrg"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<EditText
android:id="#+id/addParkingActivity_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="הערות נוספות"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<LinearLayout
android:id="#+id/ll_radioG6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<EditText
android:id="#+id/addParkingActivity_googleMapsY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="ערך עשרוני שני \n בגוגל מפות"
android:inputType="number"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="12sp" />
<EditText
android:id="#+id/addParkingActivity_googleMapsX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="ערך עשרוני ראשון \n בגוגל מפות"
android:inputType="number"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="12sp" />
</LinearLayout>
<EditText
android:id="#+id/addParkingActivity_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:ems="10"
android:hint="סוג חניון או בעלות"
android:paddingHorizontal="16dp"
android:textColor="#ffff"
android:textDirection="rtl"
android:textSize="18sp" />
<LinearLayout
android:id="#+id/ll_radioG4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="#FFA3D2E9"
android:gravity="center_horizontal"
android:layoutDirection="rtl"
android:orientation="horizontal"
android:textDirection="rtl">
<Button
android:id="#+id/addParkingActivity_buttonADD_PARKING"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:background="#drawable/roundedbutton"
android:onClick="onAddParkingPressed"
android:text=" הוסף חנייה"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
</ScrollView>
First, I believe you are missing the 'android' namespace declaration:
xmlns:android="http://schemas.android.com/apk/res/android"
Should go in your ScrollView.
Second, I would make the ScrollView take up the entire screen so change it's height from:
android:layout_height="wrap_content"
to "match_parent":
android:layout_height="match_parent"
Also, remove the layout_weight from all the elements that should be vertically stacked. I see these: ll_radioG1, ll_radioG2, ll_radioG3, ll_radioG5, ll_radioG6, ll_radioG4
You're basically asking those widgets to expand infinitely, because in a ScrollView you have unbounded vertical space.
Ok this is really weird but i fixed the issue by coping the xml code to another layout file. I guess the first xml file got corrupted after doing a lot of changes and importing a lot of libraries. Thank you #DataDino for the help!
Related
I am trying to develop a simple app for project management. The problem is with the xml layout of the app screens. The app screens are proportionally not very well put in different devices. Some elements are even hidden in some devices due to lack of space.
I already tried using both linear layout and relative layout. I've always used the "Match_parent" attribute to both the width and height of the relative layout and linear layout parent block. But still in some screen sizes, some elements are not showing, they are below the display area.
<RelativeLayout
android:id="#+id/layout1"
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="#color/white"
tools:context=".login"
android:paddingTop="20dp"
>
<ImageView
android:id="#+id/loginImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/login_logo"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="#+id/loginText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="LOGIN"
android:textColor="#color/orange"
android:textSize="50sp"
android:layout_below="#id/loginImage"
/>
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/logintextbackground"
android:layout_centerHorizontal="true"
android:layout_below="#id/loginText"
android:hint="Username"
android:textColorHint="#color/lightOrange"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/lightOrange"
android:maxLength="15"
/>
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/logintextbackground"
android:layout_centerHorizontal="true"
android:layout_below="#id/username"
android:hint="Password"
android:textColorHint="#color/lightOrange"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/lightOrange"
android:inputType="textPassword"
android:maxLength="16"
/>
<Button
android:id="#+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/login_button"
android:layout_below="#id/password"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="#+id/orText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="or"
android:textSize="20dp"
android:textColor="#color/orange"
android:layout_below="#id/loginButton"
android:layout_centerHorizontal="true"
/>
<Button
android:id="#+id/signUpButtonLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/signup"
android:layout_below="#id/loginButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
/>
Put a ScrollView as parent of your RelativeLayout and you should be fine. Refer code below :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<RelativeLayout
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:paddingTop="20dp"
tools:context=".login">
<ImageView
android:id="#+id/loginImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/login_logo" />
<TextView
android:id="#+id/loginText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/loginImage"
android:layout_centerHorizontal="true"
android:text="LOGIN"
android:textColor="#color/orange"
android:textSize="50sp" />
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/loginText"
android:layout_centerHorizontal="true"
android:background="#drawable/logintextbackground"
android:hint="Username"
android:maxLength="15"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/lightOrange"
android:textColorHint="#color/lightOrange" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/username"
android:layout_centerHorizontal="true"
android:background="#drawable/logintextbackground"
android:hint="Password"
android:inputType="textPassword"
android:maxLength="16"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/lightOrange"
android:textColorHint="#color/lightOrange" />
<Button
android:id="#+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/password"
android:layout_centerHorizontal="true"
android:background="#drawable/login_button" />
<TextView
android:id="#+id/orText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/loginButton"
android:layout_centerHorizontal="true"
android:text="or"
android:textColor="#color/orange"
android:textSize="20dp" />
<Button
android:id="#+id/signUpButtonLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/loginButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#drawable/signup" />
</RelativeLayout>
</ScrollView>
For future development, I would suggest you to use ConstraintLayout instead of LinearLayout or RelativeLayout as it provides less nesting of the views.
I'm trying to reduce the number of hierarchies on my list item so I have only one RelativeLayout, but I'm struggling to understand how can I do the same behave of a LinearLayout.
For example:
<RelativeLayout
android:id="#+id/ordercardcontentrow"
android:layout_width="match_parent"
local:MvxBind="BackgroundColor NativeColor(BackgroundColour)"
android:layout_marginBottom="4dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_height="match_parent">
<TextView
android:layout_marginTop="10dp"
android:layout_toRightOf="#id/order_classification_image"
android:id="#+id/order_header"
style="#style/NormalText.Regular"
android:layout_width="160dp"
android:textSize="#dimen/text_size_small"
android:ellipsize="end"
android:singleLine="true"
local:MvxBind="Text OrderHeader" />
<TextView
android:layout_marginTop="2dp"
android:layout_toRightOf="#id/order_classification_image"
android:id="#+id/post_code"
android:layout_below="#id/order_header"
style="#style/TitleText.Regular"
android:textSize="#dimen/text_size_vlarge"
android:ellipsize="end"
android:singleLine="true"
local:MvxBind="Text Postcode; Visible IsDelivery" />
<TextView
android:layout_marginTop="2dp"
android:layout_toRightOf="#id/order_classification_image"
android:id="#+id/order_id"
style="#style/NormalText.Medium"
android:layout_below="#id/post_code"
android:textSize="#dimen/text_size_vsmall"
android:textColor="#color/dark_grey"
local:MvxBind="Text FormattedOrderId" />
</RelativeLayout>
But if the middle one is not visible of course the are not going to be vertically centred in my relative layout, how can I make this happen?
Cheers!
Try that (adapt it to your needs):
remember, android:layout_width and height are mandatory.
<RelativeLayout
android:id="#+id/ordercardcontentrow"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp">
<TextView
android:id="#+id/order_header"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:text="AAAA" />
<TextView
android:visibility="gone"
android:id="#+id/post_code"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_below="#id/order_header"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:text="BBBB" />
<TextView
android:id="#+id/order_id"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_below="#id/post_code"
android:layout_marginTop="2dp"
android:text="CCCC"
/>
</RelativeLayout>
Use gravity center android:gravity="center" for relativelayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ordercardcontentrow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:gravity="center">
<TextView
android:id="#+id/order_header"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:text="sdff" />
<TextView
android:id="#+id/post_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/order_header"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:text="sdff" />
<TextView
android:id="#+id/order_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/post_code"
android:layout_marginTop="2dp"
android:text="sdff" />
</RelativeLayout>
Good day.I have an set of buttons which should be aligned to the bottom always,but they all also should be below an text,and it goes like this,if text is large,it is going just to push the buttons inside the scrollview,otherwise the buttons should be aligned to the parent bottom.Issue is that i add both of the tags to the linear layout wrapper of the buttons,but as soon as i set visibility of text to gone,the view just pops up and not aligning to parent bottom,here is the actual code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/single_product_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/single_product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:src="#drawable/img_placeholder" />
<RelativeLayout
android:id="#+id/basket_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_divider"
android:layout_alignEnd="#+id/single_product_divider"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/basket_success_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginLeft="26dp"
android:src="#drawable/success_icon" />
<TextView
android:id="#+id/basket_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/basket_success_icon"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/basket_success_icon"
android:text="#string/product_added_to_basket_text"
android:textColor="#ffffff"
android:textSize="16sp" />
</RelativeLayout>
<View
android:id="#+id/single_product_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/single_product_image"
android:layout_margin="25dp"
android:background="#D1D3D4">
</View>
<TextView
android:id="#+id/single_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_divider"
android:text="#string/loading_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_weight_and_servings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_name"
android:layout_marginTop="5dp"
android:text="#string/weight_and_servings_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_weight_and_servings"
android:layout_alignStart="#+id/single_product_weight_and_servings"
android:layout_below="#+id/single_product_weight_and_servings"
android:layout_marginTop="15dp"
android:text="$12.09"
android:textColor="#009444"
android:textSize="17sp"
android:textStyle="bold" />
<RatingBar
android:id="#+id/single_product_rating"
style="#style/Base.Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_price"
android:layout_alignStart="#+id/single_product_price"
android:layout_below="#+id/single_product_price"
android:layout_marginTop="5dp"
android:numStars="5" />
<TextView
android:id="#+id/single_product_rating_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating"
android:text="10.0/10"
android:textColor="#231F20"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_review_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating_text"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating_text"
android:text="8 reviews"
android:textColor="#EC2027"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_stock_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/single_product_review_count"
android:layout_marginRight="10dp"
android:text="In stock"
android:textColor="#939598" />
<View
android:id="#+id/single_product_center_divider"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/single_product_rating"
android:layout_centerHorizontal="true"></View>
<Spinner
android:id="#+id/single_product_weight_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="10dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<Spinner
android:id="#+id/single_product_type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="2dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_type_spinner"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<RelativeLayout
android:id="#+id/single_product_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="#string/add_to_cart_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_add_to_cart_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_info_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_nutritional_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_nutritional_info_button"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_reviews_text"
android:textAllCaps="false"
android:textColor="#231F20" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Can anyone please give any suggestion?
Edit : The full code of the view,actual buttons are inside RelativeLayout at the bottom of xml files there are 4 of buttons.The wrapper is single_product_buttons_wrapper
Add android:gravity="bottom" to LinearLayout containing buttons. It will work have tested it.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:gravity="bottom"
android:orientation="vertical">
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_info_button"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="123"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_nutritional_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="234"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_reviews_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="5555"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="99999"
android:textAllCaps="false"
android:textColor="#231F20" />
</LinearLayout>
</RelativeLayout>
Please view the image below:
The first image is the layout I did and it show normally on my device and another test devices. The second image is the layout showed on my friend device, it is reversed. I do not know why, and it just happened on few devices.
This is my layout code on xml.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:auto="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.ComposeSmsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_action" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="#dimen/padding_5">
<com.hnib.smslater.views.FlowLayout
android:id="#+id/layout_name_recipient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_10"
android:fontFamily="sans-serif-light"
android:orientation="horizontal">
</com.hnib.smslater.views.FlowLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padding_10">
<com.hnib.smslater.views.ClearableAutoContactCompleteTextView
android:id="#+id/et_recipient"
android:layout_width="#dimen/width_et_contact"
android:layout_height="#dimen/height_et_default"
android:layout_centerVertical="true"
android:layout_marginTop="#dimen/margin_10"
android:background="#drawable/drawable_radius_gray_gray"
android:fontFamily="sans-serif-light"
android:hint="#string/to_"
android:imeOptions="actionDone"
android:padding="#dimen/padding_5"
android:textColorHint="#color/gray"
android:textSize="18sp"
android:textStyle="bold"
auto:displayPhotoIfAvailable="false"
auto:styleOfTypedLetters="bold"
auto:typeOfData="phone"
auto:typedLettersHaveDifferentStyle="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_5"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:fontFamily="sans-serif-light"
android:text="#string/message"
android:textColor="#color/gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_message_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:text="160/1" />
</RelativeLayout>
<com.hnib.smslater.views.ActionEditText
android:id="#+id/et_text_content"
android:layout_width="match_parent"
android:layout_height="#dimen/height_et_big"
android:layout_marginLeft="#dimen/margin_5"
android:background="#drawable/drawable_radius_gray_gray"
android:ems="10"
android:fontFamily="sans-serif-light"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="10"
android:padding="#dimen/padding_5"
android:scrollbars="vertical" />
<RelativeLayout
android:id="#+id/layout_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="#dimen/padding_10"
android:showDividers="middle">
<TextView
android:id="#+id/tv_title_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#drawable/drawable_radius_acent_gray"
android:fontFamily="sans-serif-light"
android:padding="#dimen/padding_5"
android:text="#string/time"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/tv_title_time"
android:divider="?android:attr/dividerVertical"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/padding_10"
android:showDividers="middle">
<TextView
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_textview"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:text="12/06/2016"
android:textColor="#color/gray"
android:textSize="27sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/selector_textview"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:text="09:10"
android:textColor="#color/gray"
android:textSize="27sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/padding_10">
<TextView
android:id="#+id/tv_title_repeat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="30dp"
android:background="#drawable/drawable_radius_acent_gray"
android:fontFamily="sans-serif-light"
android:padding="#dimen/padding_5"
android:text="#string/repeat"
android:textAllCaps="true" />
<Spinner
android:id="#+id/spinner_repeat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Spinner>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_choose_sim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/padding_10">
<TextView
android:id="#+id/title_choose_sim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="30dp"
android:background="#drawable/drawable_radius_acent_gray"
android:fontFamily="sans-serif-light"
android:padding="#dimen/padding_5"
android:text="#string/choose_sim"
android:textAllCaps="true" />
<Spinner
android:id="#+id/spinner_choose_sim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Spinner>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/padding_10">
<TextView
android:id="#+id/tv_title_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:background="#drawable/drawable_radius_acent_gray"
android:fontFamily="sans-serif-light"
android:padding="#dimen/padding_5"
android:text="#string/ask_before_send"
android:textAllCaps="true" />
<CheckBox
android:id="#+id/checkbox_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/tv_title_confirm" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Please have a help on this issue. Thanks.
The language on your friend's phone is probably different from yours, leading to the app giving a read from right to left, rather than your left to right. Does your friend have his phone's settings on language set to Hebrew or Arabic?
Edit: please take note of the answers below mine, those are the viable options for your friend's phone, besides for changing the language of course.
You should remove android:supportsRtl="true"
from the <application> element in your AndroidManifest.xml file.
You should ADD : android:supportRTL="false"
In the manifest
I have tried everything but not succeed yet.
What Happening. When title text is small it should come in center of parent which works perfectly, but when text size is big its overlapped to its left sided component
What i want : it shouldn't not overlap but comes to next of settings Textview. it should be adjust when size increased.
small size
big size
Code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/darker_gray" >
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Settings"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:textColor="#android:color/holo_orange_dark"
android:textSize="16.0sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_toLeftOf="#+id/txtBack"
android:textColor="#android:color/white"
android:textSize="19sp" />
</RelativeLayout>
Because you are using match_parent for those two TextViews, that is why they will being overlapped, based on your code, you can try to add a fix padding for the second TextView. For example, we consider the width of the first TextView's text "Settings" is 100dp, so we can change the code as below.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/darker_gray" >
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Settings"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:textColor="#android:color/holo_orange_dark"
android:textSize="16.0sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingLeft="100dp"
android:paddingRight="100dp"
android:gravity="center"
android:layout_toLeftOf="#+id/txtBack"
android:textColor="#android:color/white"
android:textSize="19sp" />
</RelativeLayout>
set id to your first TextView and then make second TextView toRightOf first one.
Like This
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/darker_gray" >
<TextView
android:id="#+id/textview1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Settings"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:textColor="#android:color/holo_orange_dark"
android:textSize="16.0sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#id/textview1"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_toLeftOf="#+id/txtBack"
android:textColor="#android:color/white"
android:textSize="19sp" />
</RelativeLayout>
I hope this will help.
Try this,
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/darker_gray" >
<TextView
android:id="#+id/txtSetting"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Settings"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:textColor="#android:color/holo_orange_dark"
android:textSize="16.0sp" />
<TextView
android:layout_toRightOf="#+id/txtSetting"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_toLeftOf="#+id/txtBack"
android:textColor="#android:color/white"
android:textSize="19sp" />
</RelativeLayout>
Use layout_toLeftOf ,alignParentLeft and alignParentRight
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:id="#+id/txtBack"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/selectaccount"
android:textColor="#android:color/holo_orange_dark"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_alignParentRight="true"
android:textColor="#android:color/white"
android:textAppearance="?android:attr/textAppearanceMedium" />
Just Replace Your Code By Below:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#android:color/darker_gray" >
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Settings"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:textColor="#android:color/holo_orange_dark"
android:textSize="16.0sp"
android:id="#+id/txtSettings" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_toRightOf="#+id/txtSettings"
android:layout_toLeftOf="#+id/txtBack"
android:textColor="#android:color/white"
android:textSize="19sp" />
</RelativeLayout>
change second textview to this:
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hiiiiiiiiiiiii StackOverflower!!!!!!!!!!!"
android:padding="4dp"
android:gravity="center"
android:layout_toRightOf="#+id/firstTextview"
android:textColor="#android:color/white"
android:textSize="19sp" />