How can I design this layout in android? - android

How to add this, a clickable image inside edittext and also a button with EditText, how can I design this using android?

This should work:
<?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="wrap_content"
android:background="#color/colorAccent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/button"
android:drawableLeft="#drawable/ic_back_navigation" />
<ImageButton
android:id="#+id/clickableImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/button"
android:background="#android:color/transparent"
android:src="#drawable/ic_back_navigation" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="ADD" />
</RelativeLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_weight="1"
android:layout_width="wrap_content"
android:drawableRight="#mipmap/ic_launcher"
android:layout_height="wrap_content" />
<Button
android:text="ADD"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

Related

Want to create an app in which it shows 3 button vertically and horizontally at the center but when I have tried only the 3rd button was there ,

I want to create an app which shows 3 buttons but when I run my code it shows the third button not other ones have this code here -->
Here is my screenshot(https://i.stack.imgur.com/Ih3mK.png)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:text="button1" android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<Button
android:id="#+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="button2"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
<Button
android:id="#+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="button3"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
</RelativeLayout>```
[enter image description here][2]
[1]: https://i.stack.imgur.com/Ih3mK.png
[2]: https://i.stack.imgur.com/vLjRr.png![enter image description here](https://i.stack.imgur.com/gM59v.png)![enter image description here](https://i.stack.imgur.com/TRLj3.png)
Here is the code I am sharing to show 3 Buttons horizontal and vertical with LinearLayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b4" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b5" />
</LinearLayout>
Here is the screen shot I am attaching...
Try below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="button1" />
<Button
android:id="#+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="button2"
/>
<Button
android:id="#+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="button3"
/>
</LinearLayout>

Android studio horizontal layout troubles

So, I'm trying to get something like this.
And I am having a problem lining up the + and - buttons in the same line.
Once I have the horizontal layout, and I drag the buttons. I end up with this. I don't know how to make it work, from code or design window. Please help.
Any solution?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<Button
android:id="#+id/suma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="171dp"
android:layout_weight="1"
android:onClick="incrementaContador"
android:text="+" />
<Button
android:id="#+id/resta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="169dp"
android:layout_weight="1"
android:onClick="restaContador"
android:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="Cafe del dia "
android:textAlignment="center" />
<TextView
android:id="#+id/contadorA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="64dp"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/reinicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Reinicio"
android:onClick="reseteaContador" />
</RelativeLayout>
I think you need something like this. Paste this code in your code window.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:id="#+id/titulo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="Cafe del dia " />
<TextView
android:id="#+id/contadorA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titulo"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:text="4"
android:textSize="24sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contadorA"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:orientation="horizontal">
<Button
android:id="#+id/suma"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="16dp"
android:onClick="incrementaContador"
android:text="+"
android:textSize="30sp" />
<Button
android:id="#+id/resta"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="16dp"
android:onClick="restaContador"
android:text="-"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/reinicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:onClick="reseteaContador"
android:text="Reinicio" />
</RelativeLayout>
From my point of view, it is easier to get appropriate design by coding it. I am having something like this.
You've got
android:layout_alignParentTop="true"
android:layout_marginTop="171dp"
on one button and
android:layout_alignParentTop="true"
android:layout_marginBottom="169dp"
on the other.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="horizontal">
<Button
android:id="#+id/suma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:onClick="incrementaContador"
android:text="+" />
<Button
android:id="#+id/resta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:onClick="restaContador"
android:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Cafe del dia "
android:textAlignment="center" />
<TextView
android:id="#+id/contadorA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/reinicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Reinicio"
android:onClick="reseteaContador"
/>
</RelativeLayout>
You have too many nested views. You could just use a vertical Linear Layout as parent viewgroup and a horizontal linear layout with layout weight 1 for the middle two buttons.
For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Cafe del dia "
android:textAlignment="center" />
<TextView
android:id="#+id/contadorA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:textSize="24sp"
android:text="24"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1">
<Button
android:id="#+id/suma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="30dp"
android:onClick="incrementaContador"
android:text="+" />
<Button
android:id="#+id/resta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="restaContador"
android:text="-" />
</LinearLayout>
<Button
android:id="#+id/reinicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Reinicio"
android:onClick="reseteaContador" />
</LinearLayout>
Best if you use constraintLayout once you learn to use it.
You should instead use a ConstraintLayout to achieve what you want. It will be more efficient than using a RelativeLayout, especially nesting sub-layouts inside it. With the ConstraintLayout, you can use the GUI builder to drag the elements around the screen and get them pixel-perfect. The ConstraintLayout may require a bit of work but it is really powerful and you can get major performance gains when you have complex Viewgroup hierarchies consisting of many nested ViewGroups.
But as a solution to your problem here is the updated code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="horizontal">
<Button
android:id="#+id/suma"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginRight="15dp"
android:onClick="incrementaContador"
android:textSize="35sp"
android:text="+" />
<Button
android:id="#+id/resta"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginLeft="15dp"
android:onClick="restaContador"
android:textSize="35sp"
android:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Contender"
android:textAlignment="center" />
<TextView
android:id="#+id/contadorA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="35sp"
android:text="4"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/reinicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:onClick="reseteaContador"
android:text="Reinicio"
/>
</RelativeLayout>
See on the picture the property that will put text box below the button.
Then you get the squigly line in red circle indicating the relation.
How to space it even further down the page, I'm still working on. (you could use padding, but I'm sure there is better solution)
click

How to put a textview behind a button?

I have this problem, that I want to elevate my "Menu" buttons but the elevation bugs and it looks like this. I figured butting an empty TextView behind them and elevating it. Yet when I do this it gets in front of the buttons and visually covers them, yet the buttons are still functioning (it looks like this). I made it to be created before the buttons, yet it still doesn't work. How to fix it?
Edit: activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PortfolioActivity">
<TextView
android:id="#+id/Background_for_buttons"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#android:color/white"
android:elevation="10dp"
android:gravity="center"
android:textColor="#FF000000" />
<Button
android:id="#+id/portfolio_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#android:color/white"
android:text="Portfolio" />
<Button
android:id="#+id/settings_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:background="#android:color/white"
android:text="Settings" />
<Button
android:id="#+id/home_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#android:color/white"
android:text="Overview" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="226dp"
android:padding="20dp"
android:background="#android:color/white"
android:elevation="20dp"
android:text="ASDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" />
<Button
android:id="#+id/add_coin_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="ADD" />
</RelativeLayout>
Your approach is wrong. Use the code below, I just used a horizontal LinearLayout inside a vertical LinearLayout for your menu, and removed your textView. WeightSum is used so that all your 3 buttons will have the same width and fill the screen width.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PortfolioActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="#+id/home_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:background="#android:color/white"
android:text="Overview" />
<Button
android:id="#+id/portfolio_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:background="#android:color/white"
android:text="Portfolio" />
<Button
android:id="#+id/settings_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:background="#android:color/white"
android:text="Settings" />
</LinearLayout>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="226dp"
android:background="#android:color/white"
android:elevation="20dp"
android:padding="20dp"
android:text="ASDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" />
<Button
android:id="#+id/add_coin_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="ADD" />
</LinearLayout>
</RelativeLayout>

How can I align views justify in LinearLayout?

I want to align two buttons left and right and I'm using layout_weight property width .25 for both of buttons. But when I did it, buttons width are became %50.
This is what I want:
This is what I have:
And this is my XML layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageButton
android:id="#+id/like"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:textColor="#212121"
android:background="#drawable/button_default"
android:layout_margin="5dp"
android:src="#drawable/like" />
<Button
android:text="NEXT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:textColor="#FFFFFF"
android:background="#drawable/button_primary"
android:layout_margin="5dp"/>
</LinearLayout>
How can I do this?
Try this code.
<?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="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:weightSum="2">
<ImageButton
android:id="#+id/like"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#mipmap/ic_launcher"
android:src="#mipmap/ic_launcher"
android:textColor="#212121" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#mipmap/ic_launcher"
android:text="NEXT"
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
Do it like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="#+id/like"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="#drawable/button_default"
android:src="#drawable/like"
android:textColor="#212121" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/button_primary"
android:text="NEXT"
android:textColor="#FFFFFF" />
</LinearLayout>
or like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/like"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="5dp"
android:background="#drawable/button_default"
android:src="#drawable/like"
android:textColor="#212121" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:background="#drawable/button_primary"
android:text="NEXT"
android:textColor="#FFFFFF" />
</RelativeLayout>

Spinner UI example in android

Here is my UI xml file example which has 3 Spinners Currently its showing in 3 different rows.
But I wanted it in single row (1 row 3 column).
<?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" >
<Spinner
android:id="#+id/spinHour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="124dp" />
<Spinner
android:id="#+id/spinMin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/spinHour" />
<Spinner
android:id="#+id/spinRepeat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/spinMin" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/spinRepeat"
android:text="Submit" />
</RelativeLayout>
Thanks in advance.
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/spinHour"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Spinner
android:id="#+id/spinMin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="#+id/spinRepeat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" />
</LinearLayout>
TRY THIS CODE..................
YOU CAN USE LinearLayout to put your spinner in same row..
use android:layout_weight property for view your spinner same size..
<?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/linear_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="#+id/spinHour"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Spinner
android:id="#+id/spinMin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Spinner
android:id="#+id/spinRepeat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_spinner"
android:text="Submit" />
</RelativeLayout>

Categories

Resources