I have a problem: the buttons from b0 to b9 and the button "Raspuns_user" are not visible on the screen.
How should I use Relative and Linear Layout in this case?
The buttons from b0 to b9 are keyboard numbers and I've put them in a LinearLayout beacuse I want them to stay in rows.
Any suggestions?
thank you!
<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="fill_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MyActivity"
android:background="#drawable/banda"
android:screenOrientation="portrait"
android:id="#+id/banda_bk"
android:clickable="false"
android:visibility="visible">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/ImageView1"
android:src="#drawable/obj1"
android:visibility="gone"
android:layout_marginRight="67dp"
android:layout_alignTop="#+id/printfirst"
android:layout_alignRight="#+id/answer"
android:layout_alignEnd="#+id/answer" />
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/ImageView2"
android:layout_marginTop="78dp"
android:src="#drawable/obj2"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="121dp"
android:visibility="gone"/> <!-- la inceput toate invisible-->
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/ImageView3"
android:layout_marginTop="78dp"
android:src="#drawable/obj3"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="121dp"
android:visibility="gone"/> <!-- la inceput toate invisible-->
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/ImageView4"
android:layout_marginTop="78dp"
android:src="#drawable/obj4"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="121dp"
android:visibility="gone"/> <!-- la inceput toate invisible-->
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/ImageView5"
android:layout_marginTop="78dp"
android:src="#drawable/obj5"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="121dp"
android:visibility="gone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Scor"
android:id="#+id/textViewScor"
android:layout_marginRight="34dp"
android:textColor="#color/textbody"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberSigned"
android:ems="10"
android:id="#+id/answer"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="visible"
android:text="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/printfirst"
android:layout_alignParentTop="true"
android:layout_alignLeft="#+id/textViewScor"
android:layout_alignStart="#+id/printfirst"
android:layout_marginTop="23dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/printsecond"
android:layout_below="#+id/printfirst"
android:layout_alignLeft="#+id/printfirst"
android:layout_alignStart="#+id/printfirst"
android:layout_marginTop="26dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Raspunsul tau"
android:id="#+id/button"
android:layout_alignBaseline="#+id/answer"
android:layout_alignBottom="#+id/answer"
android:layout_alignRight="#+id/printsecond"
android:layout_alignEnd="#+id/printsecond" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/correctanswer"
android:layout_below="#+id/printsecond"
android:layout_alignRight="#+id/printsecond"
android:layout_alignEnd="#+id/printsecond"
android:layout_marginTop="24dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Verifica si genereaza alte nr"
android:id="#+id/buton2"
android:layout_alignTop="#+id/correctanswer"
android:layout_alignRight="#+id/printsecond"
android:layout_alignEnd="#+id/printsecond" />
<LinearLayout
android:id="#+id/row0"
android:layout_width="match_parent"
android:layout_height="0dp">
<TextView
android:id="#+id/Raspuns_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:maxLines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="40sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/row1"
android:layout_width="match_parent"
android:layout_height="0dp">
<Button
android:id="#+id/b0"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b0"
android:textSize="25sp" />
<Button
android:id="#+id/b1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b1"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b2"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b3"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b4"
android:textSize="25sp"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="#+id/row2"
android:layout_width="match_parent"
android:layout_height="0dp">
<Button
android:id="#+id/b5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b5"
android:textSize="25sp"
android:visibility="visible"
android:focusableInTouchMode="false"
android:enabled="false" />
<Button
android:id="#+id/b6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b6"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b7"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:text="#string/b8"
android:textSize="25sp"
android:visibility="visible" />
<Button
android:id="#+id/b9"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:text="#string/b9"
android:textSize="25sp"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
Change the layout_height="0dp to wrap_content and also set the
android:layout_width="0dp" from the buttons to android:layout_width="wrap_content"
Change the height of Linear layout from
android:layout_height="0dp"
to
android:layout_height="wrap_content"
Solution :
Problem with Your layout is that you have used android:layout_height="0dp"
instead of that use android:layout_height="wrap_content"
More Info :
LinearLayout is used to set layout childs either HORIZONTAL or VERTICAL.
So it set positions as you declared in XML but it doesn't happen with RelativeLayout.
In RelativeLayout you have to set positions of your childViews.
Its the basic difference between both layouts..
You are using RelativeLayout
It uses properties like below to set positions of ChildViews in layout screen
android:layout_above
android:layout_below
android:layout_toLeftOf
android:layout_toRightOf
read about Layouts for more details...
Hope this helps...
Related
Is there a way to do this in android studio? I want to achieve that when you scroll down the header will overlap above and under is the scrollview part. What I've got is it scrolls over the header. In android studio
This is what Im trying to achieve that was made in figma
Default
When you scroll
So far this is what my code looks like
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Fragment.RecordFragment"
android:orientation="vertical">
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="100dp">
<TextView
android:id="#+id/txtDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="128dp"
android:text="Date for today"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="316dp"
android:layout_height="201dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:background="#drawable/sec_bp" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="70dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="SBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="120dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="DBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="170dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="BPM" />
<Button
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="210dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:text="save" />
</RelativeLayout>
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try adding elevation inside your header view. like this :
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/
android:elevation="1dp">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp"
android:elevation="2dp"/>
I set the View elevation 1dp and the TextView 2dp so that the text can still in front of the View.
I am pasting the layout below.
It have outer Relative layout, and inside it there are two layouts whose ids are l_first(linear layout) and slider(relative layout). THis slider layout is a layout I want aaligned to the bottom of the device screen and should take the height of the contents(several layouts and views) inside it. bottom of l_first should be positioned between top of the screen and top of slider.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/l_first">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="1"
android:id="#+id/slider"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</RelativeLayout>
To reach your goal you should use a linear layout
make it like this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/l_first"
android:layout_weight="1">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/slider"
android:orientation="vertical"
android:gravity="bottom"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
There are two important notes :
Your linear layout should have gravity bottom, it means it calculate the height from the bottom.
the view which you want to get the rest of space should have weight of 1 !!!
This question already has answers here:
How do you make a LinearLayout scrollable?
(10 answers)
Closed 3 months ago.
I am having a popup view in an android app. For the portrait screen the popup page showing properly, but if i rotate the screen to landscape the popup layout display partially. I have click buttons in the popup. Can't view the buttons in landscape mode. The popup page i am using is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
How can i display the full page in the screen in landscape or for small screens? Any help would be appreciated. Thanks in advance.
Check This I used your xml(change your background):-
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<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" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/ic_launcher"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Try this as you know ScrollView can have only one child so you put the ScrollView as parent Layout and then One child will be the linearlayout and then that will work. Try like this:
<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:fillViewport="true">
<LinearLayout
android:id="#+id/popup_element"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
But it is better that you use RelativeLayout instead of using so many linearlayouts. Hope it helps.
A ScrollView is a FrameLayout, meaning you must place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.
So you have to solve your problem with concept clearing you can follow my answer of this question. may it will clear your concept and help to solve your problem.
you can only take single tag(Child Layout) in scrollview. if you have put multiple Linear Layout then take single linearlayout and then put other Linear Layout in this.
In my application i am using recycler view and scrollview in one layout. it is not working when i am using both these views. If i remove scroll view only the recycler view is working. Plese any one help me hoe to fix this issue.
my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/r1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
>
<ScrollView
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1e356a">
<TextView
android:id="#+id/placce_head"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Hyderabad to banglore"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Selected Seats"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/totalamount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Total Amount"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seat_num"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/total_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/boardingpoint_edttxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint=" Select Boarding Point"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/contact_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Contact Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<EditText
android:id="#+id/contactname_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Name"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/email_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Email Address"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/contactnum_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/emergency_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Emergency Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/passenger_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Passenger Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/view"
android:layout_below="#+id/sc"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<LinearLayout
android:id="#+id/coupon_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="8dp"
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="100" >
<EditText
android:id="#+id/entercouponcode_edt"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="50"
android:hint="Enter coupn code"
android:inputType="text" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bt_apply"
style="#style/payment_button_style"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="-5dp"
android:layout_weight="40"
android:gravity="center"
android:text="Apply" />
</LinearLayout>
<Button
android:id="#+id/pay_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#F93249"
android:duplicateParentState="true"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Proceed to Pay"
android:textColor="#ffffff"
android:textSize="20dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
you must know that ,your scrollview property is set as MatchParent ,which means it will fill the content view, so i suggest to set Height a real value such as 100dp, and it will work
You need to dynamically change the height of the recyclerview, depending on how many items you have.
int recyclerheight = height_per_item * adapterData.size();
recyclerView.getLayoutParams().height = recyclerheight;
The scroll view blocks the recyclerview from changing its height set in the xml, that's why you need to do it programically.
I'm trying to create two number pickers in android. However i try to center them both at the bottom. I tried to mix up relative and linear layout, but i was not able to fix it.
The images shows how the buttons are placed at the moment. The red squares show how i want the buttons to be displayed.
Hope you can help me.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.pvdl.ndwatch.NDwatchActivity$PlaceholderFragment" >
<ImageView
android:id="#+id/background"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="#drawable/background" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/nd_text"
android:textColor="#color/red"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:src="#drawable/ic_launcher" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginLeft="150dp"
android:layout_marginTop="90dp"
android:background="#00ABCC" />
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="20dp"
android:text="#string/title"
android:textColor="#404041"
android:textSize="60sp" />
<TextView
android:id="#+id/title2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="30dp"
android:text="#string/title2"
android:textColor="#404041"
android:textSize="50sp" />
<RelativeLayout
android:id="#+id/frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_centerHorizontal="true" >
</RelativeLayout>
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="270dp"
android:layout_height="270dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:indeterminate="false"
android:max="100"
android:progress="0"
android:progressDrawable="#drawable/circular_progress_bar" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignBottom="#+id/background"
android:layout_centerHorizontal="true"
android:layout_marginBottom="60dp"
android:background="#android:color/transparent"
android:onClick="onNDstart"
android:scaleType="fitXY"
android:src="#drawable/custom_button" />
<Chronometer
android:id="#+id/chronometer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/imageButton1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:background="#android:color/transparent"
android:text="Chronometer"
android:textColor="#000000"
android:textSize="70sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/background"
android:layout_marginBottom="40dp"
android:layout_centerHorizontal="true"
android:text="#string/start"
android:textColor="#color/red"
android:textStyle="bold" />
<NumberPicker
android:id="#+id/numberPicker2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:entries="#array/shutter_times"
/>
<NumberPicker
android:id="#+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:entries="#array/nd_values"
android:gravity="bottom" />
</RelativeLayout>
Change your xml to this:
<RelativeLayout ...>
....
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="2" >
<NumberPicker
android:id="#+id/numberPicker2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="#array/shutter_times" />
<NumberPicker
android:id="#+id/numberPicker1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="#array/nd_values" />
</LinearLayout>
</RelativeLayout>
If you want a space between the buttons just add a paddingRight to the left button and the same value to the paddingLeft of the right button.
Hope this helps.