how can I align edit text with another editText in different layouts?
(I got this error #+id/plastering_material_spinner is not a sibling in the same RelativeLayout
Layout constraints in a given RelativeLayout should reference other views within the same relative layout (but not itself!))
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentBottom="true"
android:layout_below="#id/image_Dead_Load"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:background="#drawable/layout_border"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<TextView
android:id="#+id/wall_material"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/material_thickness"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="91dp"
android:layout_marginRight="110dp"
android:paddingLeft="5sp"
android:text="نوع مصالح"
android:textColor="#color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/material_thickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="5sp"
android:text="ضخامت mm"
android:textColor="#color/black"
android:textSize="15sp" />
<RelativeLayout
android:id="#+id/brick_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/material_thickness"
android:orientation="horizontal">
<EditText
android:id="#+id/editText_wall_width"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/wall_material_spinner"
android:layout_alignTop="#+id/wall_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
<Spinner
android:id="#+id/wall_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_toLeftOf="#+id/brick_material"
android:layout_toRightOf="#+id/editText_wall_width"
android:layout_toStartOf="#+id/brick_material"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/brick_material"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/wall_material_spinner"
android:layout_alignParentRight="true"
android:text="نوع آجر"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/plastering_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/brick_layout">
<EditText
android:id="#+id/editText_plastering_material"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/plastering_material_spinner"
android:layout_alignTop="#+id/plastering_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
<Spinner
android:id="#+id/plastering_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginTop="7dp"
android:layout_toLeftOf="#+id/plastering_material"
android:layout_toRightOf="#+id/editText_plastering_material"
android:layout_toStartOf="#+id/plastering_material"
android:background="#drawable/spinner_background"
android:gravity="center_vertical"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/plastering_material"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/plastering_material_spinner"
android:layout_alignParentRight="true"
android:paddingLeft="5sp"
android:text="نوع اندود"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
</RelativeLayout>
Related
I am trying to make an android application and I need the middle part of my screen to be scrollable. When I set a ScrollView inside an Relative Layout my application crashes.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<TextView
android:id="#+id/tvCijferHalen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView"
android:layout_alignParentEnd="true"
android:layout_alignStart="#+id/etWegingTehalenCijfer"
android:layout_alignTop="#+id/textView"
android:layout_marginEnd="26dp"
android:layout_marginStart="20dp"
android:background="?android:attr/colorPressedHighlight"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/etWatStaan"
android:layout_alignEnd="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="328dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:background="#android:color/holo_green_light"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/tvCijferHalen"
android:layout_above="#+id/etWatStaan"
android:layout_alignStart="#+id/textView"
android:layout_alignEnd="#+id/tvCijferHalen">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<EditText
android:id="#+id/etcijfer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="185dp"
android:layout_marginTop="46dp"
android:ems="10"
android:hint="Cijfer 1"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<EditText
android:id="#+id/etweging1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/etcijfer1"
android:layout_alignBottom="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_marginEnd="28dp"
android:layout_marginRight="46dp"
android:layout_marginStart="187dp"
android:layout_toStartOf="#+id/bLess1"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<Button
android:id="#+id/bLess1"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging1"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/etcijfer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer1"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 2"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging1"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess2"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging2"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer2"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 3"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging2"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess3"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging3"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer3"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 4"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging3"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess3"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess4"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging4"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer4"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 5"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging4"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess4"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess5"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging5"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer5"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 6"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging5"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess5"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess6"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging6"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer6"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 7"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging6"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess6"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess7"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging7"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
</RelativeLayout>
</ScrollView>
<EditText
android:id="#+id/etWatStaan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/bNiewCijfer"
android:layout_alignEnd="#+id/etWegingTehalenCijfer"
android:layout_alignParentStart="true"
android:layout_marginEnd="200dp"
android:layout_marginRight="48dp"
android:ems="10"
android:hint="Wat wil je staan"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray" />
<EditText
android:id="#+id/etWegingTehalenCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:ems="10"
android:hint="weging"
android:inputType="number"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:layout_alignBaseline="#+id/etWatStaan"
android:layout_alignBottom="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_marginStart="187dp" />
<Button
android:id="#+id/bNiewCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="Cijfer Toevoegen"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignBottom="#+id/textView7"
android:layout_alignEnd="#+id/tvCijferHalen"
android:layout_alignStart="#+id/tvCijferHalen"
android:background="?android:attr/colorMultiSelectHighlight"
android:text="Te halen Cijfer"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/textView"
android:layout_marginTop="13dp"
android:background="#android:color/holo_green_dark"
android:text="Gemiddelde"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignEnd="#+id/ScrollView01"
android:layout_alignStart="#+id/tvCijferHalen"
android:layout_marginEnd="71dp"
android:text="Weging"
android:textAlignment="center"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignStart="#+id/ScrollView01"
android:layout_alignTop="#+id/ScrollView01"
android:layout_marginTop="31dp"
android:text="Cijfer"
android:textAlignment="center"
android:textColor="#android:color/black" />
Can someone help me ? I am wondering if it's even possible to have only a part of the screen scrollable
Try this approach:
Step 1
Use a LinearLayout as your root element to enable you to use layout_weightattribute;
Step 2
Inside your layout, you can split it into 3 parts each with a layout_weight of .3
For example:
<LinearLayout
...
orientation="vertical"
... >
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<ScrollView
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
</LinearLayout> !-- end of root layout here
I said .3 just in case you want to have the sections occupy the same size of the window; but you can set them to whatever you want according to your needs.
I hope this helps.
Note A ScrollView only accepts ONE child element!
Good luck!
If anyone could guide me what I am doing wrong in this ? I can't get my items aligned properly.
My list item
And My screen image
Here is my XML of child row. I am binding it with relative layout , then setting fixed length of image and other details are mentioned below. Please have a look. The image isn't appearing in the center as it is supposed to be.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:padding="5dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_alignBottom="#+id/Description_txt"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:padding="2dp"
android:src="#drawable/gallery" />
<TextView
android:id="#+id/Name_txt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/colorPrimaryDark"/>
<TextView
android:id="#+id/Brandname_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Name_txt"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textSize="11sp"
android:textColor="#color/black_overlay"
android:layout_alignRight="#+id/Description_txt"
android:layout_alignEnd="#+id/Description_txt" />
<TextView
android:id="#+id/Description_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Brandname_txt"
android:layout_marginLeft="5dp"
android:textSize="11sp"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textColor="#color/black_overlay" />
<TextView
android:id="#+id/Phone_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Description_txt"
android:layout_alignBottom="#+id/Description_txt"
android:layout_toEndOf="#+id/Name_txt"
android:layout_toRightOf="#+id/Name_txt"
android:text="#string/arabella"
android:textSize="11sp"
android:textColor="#color/black_overlay" />
<Button
android:id="#+id/View_btn"
android:layout_width="60dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="5dp"
android:background="#drawable/btn_view"
android:paddingLeft="5dp"
android:textColor="#android:color/white"
android:textSize="7sp" />
<TextView
android:id="#+id/Viewed_txt"
android:visibility="gone"
android:textSize="11sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/View_btn"
android:layout_alignBottom="#+id/View_btn"
android:layout_marginEnd="25dp"
android:layout_marginRight="25dp"
android:layout_toLeftOf="#+id/View_btn"
android:layout_toStartOf="#+id/View_btn"
android:text="#string/viewed"
android:textStyle="bold"
android:textColor="#color/colorPrimaryDark" />
<ImageView android:id="#+id/imgView"
android:visibility="gone"
android:src="#drawable/ic_small_view"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_toLeftOf="#+id/Viewed_txt"
android:layout_toStartOf="#+id/Viewed_txt"
android:layout_alignBottom="#+id/Name_txt" />
</RelativeLayout>
you can just change the
1 change the height of your list item layout to
android:layout_height="wrap_content"
2 change the gravity of imageView to center
Depending on what layout your using. Use either:
layout_centerVertical="true"
or
gravity="center_vertical"
Also, make the imageView smaller
Use Below XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:padding="5dp">
<ImageView
android:id="#+id/imageView1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:padding="2dp"
android:src="#drawable/saffron_flag" />
<Button
android:id="#+id/View_btn"
android:layout_width="60dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="#drawable/saffron_flag"
android:paddingLeft="5dp"
android:textColor="#android:color/white"
android:textSize="7sp" />
<TextView
android:id="#+id/Name_txt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/View_btn"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Brandname_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Name_txt"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/View_btn"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textColor="#color/black_overlay"
android:textSize="11sp" />
<TextView
android:id="#+id/Description_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Brandname_txt"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/View_btn"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textColor="#color/black_overlay"
android:textSize="11sp" />
<TextView
android:id="#+id/Phone_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginLeft="5dp"
android:layout_below="#+id/Description_txt"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/arabella"
android:textColor="#color/black_overlay"
android:textSize="11sp" />
<TextView
android:id="#+id/Viewed_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/View_btn"
android:layout_alignBottom="#+id/View_btn"
android:layout_marginEnd="25dp"
android:layout_marginRight="25dp"
android:layout_toLeftOf="#+id/View_btn"
android:layout_toStartOf="#+id/View_btn"
android:text="#string/viewed"
android:textColor="#color/colorPrimaryDark"
android:textSize="11sp"
android:textStyle="bold"
android:visibility="gone" />
<ImageView
android:id="#+id/imgView"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_alignBottom="#+id/Name_txt"
android:layout_toLeftOf="#+id/Viewed_txt"
android:layout_toStartOf="#+id/Viewed_txt"
android:src="#drawable/ic_small_view"
android:visibility="gone" />
</RelativeLayout>
I have RelativeLayout inside a scrolbar,as you see the height of relative layout doesn't fill the scrollbar height
how can I solve it?
I have another question, when I focus in an edittext the whole layut (parent layouyt) push up,I want just my layout put inside the scroll bar pushes up
<ScrollView
android:id="#+id/scrollView_main"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/image_Dead_Load"
android:layout_marginBottom="2dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:fadeScrollbars="false"
android:verticalScrollbarPosition="left">
<RelativeLayout
android:id="#+id/data_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/image_Dead_Load"
android:layout_centerHorizontal="true"
android:background="#drawable/layout_border">
<RelativeLayout
android:id="#+id/material_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/title_border">
<TextView
android:id="#+id/wall_material"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/material_thickness"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="91dp"
android:layout_marginRight="110dp"
android:paddingLeft="5sp"
android:text="جنس مصالح"
android:textColor="#color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/material_thickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="3dp"
android:paddingLeft="5sp"
android:text="ضخامت mm"
android:textColor="#color/black"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/brick_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/material_info"
android:layout_marginTop="5dp"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<EditText
android:id="#+id/editText_wall_width"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/wall_material_spinner"
android:layout_alignTop="#+id/wall_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
<Spinner
android:id="#+id/wall_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_toLeftOf="#+id/brick_material"
android:layout_toRightOf="#+id/editText_wall_width"
android:layout_toStartOf="#+id/brick_material"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/brick_material"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/wall_material_spinner"
android:layout_alignParentRight="true"
android:text="نوع آجر"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/plastering_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/brick_layout"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<EditText
android:id="#+id/editText_plastering_material"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/plastering_material_spinner"
android:layout_alignTop="#+id/plastering_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
<Spinner
android:id="#+id/plastering_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginTop="7dp"
android:layout_toLeftOf="#+id/plastering_material"
android:layout_toRightOf="#+id/editText_plastering_material"
android:layout_toStartOf="#+id/plastering_material"
android:background="#drawable/spinner_background"
android:gravity="center_vertical"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/plastering_material"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/plastering_material_spinner"
android:layout_alignParentRight="true"
android:text="نوع اندود"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/esther_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/plastering_layout"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<TextView
android:id="#+id/esther_material"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/esther_material_spinner"
android:layout_alignParentRight="true"
android:text="نوع آستر"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
<Spinner
android:id="#+id/esther_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginTop="7dp"
android:layout_toLeftOf="#+id/esther_material"
android:layout_toRightOf="#+id/editText_esther_material"
android:layout_toStartOf="#+id/esther_material"
android:background="#drawable/spinner_background"
android:gravity="center_vertical"
android:spinnerMode="dropdown" />
<EditText
android:id="#+id/editText_esther_material"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/esther_material_spinner"
android:layout_alignTop="#+id/esther_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/exterior_mortar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/esther_layout"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<TextView
android:id="#+id/exterior_mortar_material"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/exterior_mortar_material_spinner"
android:layout_alignParentRight="true"
android:text="ملات بیرونی"
android:textColor="#color/gray_heavy"
android:textSize="12sp" />
<Spinner
android:id="#+id/exterior_mortar_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginTop="7dp"
android:layout_toEndOf="#+id/editText_exterior_mortar_material"
android:layout_toLeftOf="#+id/exterior_mortar_material"
android:layout_toRightOf="#+id/editText_exterior_mortar_material"
android:background="#drawable/spinner_background"
android:gravity="center_vertical"
android:spinnerMode="dropdown" />
<EditText
android:id="#+id/editText_exterior_mortar_material"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/exterior_mortar_material_spinner"
android:layout_alignTop="#+id/exterior_mortar_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/facing_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/exterior_mortar_layout"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<TextView
android:id="#+id/facing_material"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/facing_material_spinner"
android:layout_alignParentRight="true"
android:text="نوع نما"
android:textColor="#color/gray_heavy"
android:textSize="15sp" />
<Spinner
android:id="#+id/facing_material_spinner"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginTop="7dp"
android:layout_toEndOf="#+id/editText_facing_material"
android:layout_toLeftOf="#+id/facing_material"
android:layout_toRightOf="#+id/editText_facing_material"
android:background="#drawable/spinner_background"
android:gravity="center_vertical"
android:spinnerMode="dropdown" />
<EditText
android:id="#+id/editText_facing_material"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="#+id/facing_material_spinner"
android:layout_alignTop="#+id/facing_material_spinner"
android:layout_marginRight="3dp"
android:background="#drawable/textinputborder"
android:inputType="numberDecimal"
android:paddingLeft="5sp"
android:textColor="#color/black" />
</RelativeLayout>
<Button
android:id="#+id/wall_loading_btn"
android:layout_width="150dp"
android:layout_height="36dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:background="#drawable/buttonshape"
android:gravity="center"
android:onClick="wallLoading"
android:text="محاسبه"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold"></Button>
<TextView
android:id="#+id/loading_conclusion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/wall_loading_btn"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/wall_loading_btn"
android:layout_gravity="center_horizontal"
android:layout_toLeftOf="#+id/wall_loading_btn"
android:gravity="center_horizontal|center_vertical"
android:text="جنس مصالح"
android:textColor="#color/black"
android:textSize="15sp" />
</RelativeLayout>
</ScrollView>
I have a RelativeLayout which includes a Spinner and some RadioButtons, based on the selection of these I have to hide some views and make others visible. The problem is if I make the views GONE by view.setVisibility(View.GONE) the layout gets messed up, the views overlap, if I use view.Visibility(View.INVISIBLE) everything is fine but the missing views create a void on the page. I want to push the views beneath up to properly augment the page. Below is a better explanation:
So far the code I have is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_app" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="60dp"
android:background="#drawable/drop_down" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner1"
android:layout_below="#+id/textView5"
android:layout_marginTop="30dp"
android:text="xxx"
android:textColor="#002f44"
android:textSize="18sp" />
<Button
android:id="#+id/button2"
android:layout_width="170dp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignRight="#+id/spinner1"
android:background="#drawable/btn_calendar"
android:textColor="#FFBF00" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="20dp"
android:scaleType="centerCrop" />
<AutoCompleteTextView
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/spinner1"
android:layout_alignTop="#+id/imageView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/imageView1"
android:ems="6"
android:hint="xx xx"
android:inputType="textPersonName"
android:maxLength="25"
android:textColor="#002f44" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/editText1"
android:padding="03dp"
android:textColor="#610B0B" />
<Button
android:id="#+id/button1"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:background="#drawable/btn_addreminder"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner1"
android:layout_below="#+id/spinner1"
android:layout_marginTop="20dp"
android:text="xxx "
android:textColor="#002f44"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/spinner1"
android:layout_alignTop="#+id/textView4"
android:layout_marginTop="-5dp"
android:background="#drawable/widget_style"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="xxx"
android:textColor="#002f44" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="xxx"
android:textColor="#002f44" />
</RadioGroup>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner1"
android:layout_below="#+id/radioGroup1"
android:layout_marginTop="25dp"
android:text="xxx"
android:textColor="#002f44"
android:textSize="18sp" />
<AutoCompleteTextView
android:id="#+id/autoname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignRight="#+id/spinner1"
android:ellipsize="end"
android:ems="8"
android:hint="xx xx"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#002f44" >
</AutoCompleteTextView>
<Button
android:id="#+id/button4"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/button1"
android:layout_marginLeft="05dp"
android:layout_marginTop="66dp"
android:background="#drawable/btn_addreminder"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<Button
android:id="#+id/Button01"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/btn_addreminder"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<Button
android:id="#+id/Button02"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignBaseline="#+id/button4"
android:layout_alignBottom="#+id/button4"
android:layout_alignRight="#+id/editText1"
android:background="#drawable/btn_addreminder"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
You should use alignWithParentIfMissing attribute.
I've reworked your layout, try it
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="60dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView5"
android:layout_marginTop="30dp"
android:text="xxx"
android:textColor="#002f44"
android:textSize="18sp" />
<Button
android:id="#+id/button2"
android:layout_width="170dp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignParentRight="true"
android:textColor="#FFBF00" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="20dp"
android:scaleType="centerCrop" />
<AutoCompleteTextView
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/imageView1"
android:ems="6"
android:hint="xx xx"
android:inputType="textPersonName"
android:maxLength="25"
android:textColor="#002f44" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/editText1"
android:padding="03dp"
android:textColor="#610B0B" />
<Button
android:id="#+id/button1"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="xxx "
android:textColor="#002f44"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView4"
android:layout_marginTop="-5dp"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="xxx"
android:textColor="#002f44" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="xxx"
android:textColor="#002f44" />
</RadioGroup>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/radioGroup1"
android:layout_marginTop="25dp"
android:text="xxx"
android:textColor="#002f44"
android:textSize="18sp" />
<AutoCompleteTextView
android:id="#+id/autoname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignParentRight="true"
android:ellipsize="end"
android:ems="8"
android:hint="xx xx"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#002f44" >
</AutoCompleteTextView>
<Button
android:id="#+id/button4"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/button1"
android:layout_marginLeft="05dp"
android:layout_marginTop="66dp"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<Button
android:id="#+id/Button01"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
<Button
android:id="#+id/Button02"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignBaseline="#+id/button4"
android:layout_alignBottom="#+id/button4"
android:layout_alignRight="#+id/editText1"
android:text="xxx"
android:textColor="#002f44"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Use LinearLayout(vertical) inside ScrollView and create RelativeLayouts as child of this LinearLayout. Set height of these RelativeLayout as wrap content, so that as you set visibility of items as GONE its height will shrink.
Now as per image that you have given here, you can have spinner first then below that a relative layout which will contain two (horizontal) items that you wanna hide. then next two (horizontal) items in another layout and then your image, editText and Button in third layout.
So you hide any relative layout others will arrange properly.
I would recommend to create a view of height 1dp with transparent background below texView4 and then set android:layout_below="#id/view" attribute for textView5. Here is how the changes to the layout would look like:
</RadioGroup> <!-- RadioGroup ends -->
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/textView4"
android:background="#color/transparent"/>
<!-- Changed layout_below attribute value -->
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner1"
android:layout_below="#id/view"
android:layout_marginTop="25dp"
android:text="xxx"
android:textColor="#002f44"
android:textSize="18sp" />
And here is how the layout looks like with textView4 and RadioGroup gone:
In my app am using customized listed view with text view and Buttons.The screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from layout-large folder.when i run it on device.the list view item and header display not fit to the screen like image shown below,some empty space in the end of row.Its not able to fit to the screen.Can any one know please help me to solve this issue.
Header XML Coding
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/search_lay"
android:layout_marginTop="1dp"
android:background="#e8e8e8" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:text="Item(s)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="48dp"
android:layout_toRightOf="#+id/textView1"
android:text="Price(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="#+id/textView3"
android:text="Qty"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:layout_toRightOf="#+id/textView2"
android:text="Total(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:text="Fav"
android:textColor="#dd1713"
android:textSize="13sp" />
</RelativeLayout>
Customized List-view XML Coding
<?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" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ffffff" >
<TextView
android:id="#+id/orderlist_product_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:visibility="gone" />
<RelativeLayout
android:layout_width="30dp"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/fav_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/fav_order_list_btn" />
<Button
android:id="#+id/special_inst_btn"
android:layout_width="25dp"
android:layout_height="18dp"
android:layout_below="#+id/fav_img"
android:layout_centerHorizontal="true"
android:background="#drawable/special_inst_btn_in_orderlist"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="#+id/order_list_itemname"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="1dp"
android:text="Item name"
android:textColor="#000000"
android:textSize="12sp"
android:typeface="serif" />
<RelativeLayout
android:layout_width="34dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp" >
<TextView
android:id="#+id/orderlist_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:gravity="center"
android:textColor="#298616"
android:textSize="10sp" />
<TextView
android:id="#+id/orderlist_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="right"
android:text="200.00"
android:textColor="#000000"
android:textSize="10sp"
android:typeface="serif" />
</RelativeLayout>
<Button
android:id="#+id/orderlist_minus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginTop="1dp"
android:background="#drawable/sub_button_click" />
<EditText
android:id="#+id/order_list_quantity"
android:layout_width="27dp"
android:layout_height="25dp"
android:layout_marginTop="13dp"
android:background="#drawable/et_bg"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:inputType="number"
android:textColor="#000000"
android:textSize="12dp"
android:typeface="serif" >
<requestFocus />
</EditText>
<Button
android:id="#+id/orderlist_plus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:background="#drawable/plus_btn_click" />
<TextView
android:id="#+id/orderlist_total"
android:layout_width="43dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginTop="13dp"
android:gravity="right"
android:text="1000.00"
android:textColor="#000000"
android:textSize="11sp"
android:typeface="serif" />
<Button
android:id="#+id/orderlist_delete"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_marginTop="1dp"
android:background="#drawable/order_list_delete" />
</LinearLayout>
</RelativeLayout>
i m giving u a demo.this layout will work on all size layout,this will definitely help u #Yugesh.
weight works percentage-wise on all screen.
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image1"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="30%" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
</LinearLayout>
</RelativeLayout>
further more,if there is any query,then please ask...