How to show labels next to spinners in a relativeLayout - android

I have the following RelativeLayout:
<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:orientation="horizontal" >
<RadioGroup
<!--stuff-->
</RadioGroup>
<Spinner
android:id="#+id/colour_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1" />
<TextView
android:id="#+id/colourLabel"
android:text="#string/label_colour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1"
android:layout_toLeftOf="#+id/colour_spinner"/>
<Spinner
android:id="#+id/country_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/colour_spinner" />
<TextView
android:id="#+id/countryLabel"
android:text="#string/label_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/colour_spinner"
android:layout_toLeftOf="#+id/country_spinner"/>
<Spinner
android:id="#+id/stadium_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/country_spinner" />
<TextView
android:id="#+id/stadiumLabel"
android:text="#string/label_stadium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/country_spinner"
android:layout_toLeftOf="#+id/stadium_spinner"/>
Hopefully it's obvious what I'm trying to do here. Three spinners, each below the one before, and a label to the left of each, ideally all lined up neatly.
The result I'm getting at the moment is that only the spinners show on the screen, and I get no text labels at all. What am I doing wrong here? I suspect it's to do with my layout width/height settings?

Enclose each spinner and label inside a horizontal LinearLayout:
<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">
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- stuff -->
</RadioGroup>
<LinearLayout
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup"
android:orientation="horizontal" >
<TextView
android:id="#+id/colourLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_colour" />
<Spinner
android:id="#+id/colour_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner1"
android:orientation="horizontal" >
<TextView
android:id="#+id/countryLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/label_country" />
<Spinner
android:id="#+id/country_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner2"
android:orientation="horizontal" >
<TextView
android:id="#+id/stadiumLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_stadium" />
<Spinner
android:id="#+id/stadium_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>

try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="50dip" >
</RadioGroup>
<TextView
android:id="#+id/colourLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1"
android:text="label_colour"
android:textColor="#android:color/white" />
<Spinner
android:id="#+id/colour_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup1"
android:layout_toRightOf="#+id/colourLabel" />
<TextView
android:id="#+id/countryLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/colour_spinner"
android:text="label_country"
android:textColor="#android:color/white" />
<Spinner
android:id="#+id/country_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/colour_spinner"
android:layout_toRightOf="#+id/countryLabel" />
<TextView
android:id="#+id/stadiumLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/country_spinner"
android:text="label_stadium" />
<Spinner
android:id="#+id/stadium_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/country_spinner"
android:layout_toRightOf="#+id/stadiumLabel" />
</RelativeLayout>

Related

Make the control in LinearLayout not to fill all the space

I have a layout like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fsfsdfds"
android:layout_gravity="center_vertical" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fdsfdsfds"
android:layout_gravity="center_vertical" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
It fill the whole space of the activity.
How can I make these 2 TextViews and EditTexts take only space enough to show themselves (not fill all the space) and align the button to the bottom?
I think this is what you're looking for :
<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="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView1" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/LinearLayout1"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView2" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button" />
</RelativeLayout>
EDIT :
If you don't want to use the two LinerLayouts (and therefore gain even more performance), you can do the following :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/EditText1"
android:layout_gravity="center_vertical"
android:text="TextView1" />
<EditText
android:id="#+id/EditText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_toEndOf="#id/TextView1"
android:layout_toRightOf="#id/TextView1"
android:inputType="text" />
<TextView
android:id="#+id/TextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/EditText2"
android:layout_below="#id/TextView1"
android:layout_gravity="center_vertical"
android:text="TextView2" />
<EditText
android:id="#+id/EditText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#id/EditText1"
android:layout_gravity="center_vertical"
android:layout_toEndOf="#id/TextView2"
android:layout_toRightOf="#id/TextView2"
android:inputType="text" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button" />
</RelativeLayout>
Check This.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:text="fsfsdfds" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:text="fdsfdsfds" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
You try with RelativeLayout, or else if wanted to be done with LinearLayout you need to consider weights if width is not fillparent.
Check below sample to start with ..
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:text="fsfsdfds" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.8" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:text="fdsfdsfds" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.8" />
Either convert to a relative-layout and use alignparentbottom for the button - or use layout weights for the linear-layouts

Unable to scroll listview items

I have layout with few text boxes and checkboxes. Between them is listview. When I add three or more items I can't see them in listview, the listview does not have scroll bar.
This is my layout:
<ScrollView 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:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="163dp"
android:orientation="horizontal" >
<!-- -------------HERE IS MY LISTVIEW--------------- -->
<ListView
android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutCheckBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/linearLayoutGlavni"
android:layout_below="#+id/linearLayoutGlavni"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reklamacija dobavljaču" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="14dp"
android:layout_toRightOf="#+id/checkBox"
android:text="Prenamjena robe" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Otpis robe" />
<CheckBox
android:id="#+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="111dp"
android:layout_toRightOf="#+id/checkBox3"
android:text="Upozorenje djelatniku" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/checkBox5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Obuka djelatnika" />
<CheckBox
android:id="#+id/checkBox6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="64dp"
android:layout_toRightOf="#+id/checkBox5"
android:text="Održavanje" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.68" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Is there something missing inside layout code or this must be solved through code?
You should never put a listview in a scrollView, because Listview is autoScrollable when its size increases than the screen.
Please refer to this link. Makers of Listview component.
Here you can find the best approaches of How to use a listview properly
https://www.youtube.com/watch?v=wDBM6wVEO70
I could suggest you to put only the ListView in a ScrollView. I think it will work, because I already tried it. So please try with something like this
<ScrollView
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="163dp"
<ListView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#+id/listView" />
</ScrollView>

Android - How to fix position of image

I have a LinearLayout that has a number of text fields and an ImageView to the right of the LinearLayout. However the position of the image is never fixed and shifts depending on the content of the TextView fields. How do I solve this problem ? I have tried manipulating android:layout_gravity but that does not give me a solution. I would just like my image to dock itself at the right regardless of the content of the TextViews. Here is my layout file. Any pointers or a solution would be most appreciated.
<?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="horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="144dp"
android:orientation="vertical"
android:layout_gravity="left"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/date_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date_of_birth" />
<TextView
android:id="#+id/date_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/place_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/place_of_birth" />
<TextView
android:id="#+id/place_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/height_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/height" />
<TextView
android:id="#+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/blood_type_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/blood_type" />
<TextView
android:id="#+id/blood_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/member_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
</LinearLayout>
Use RelativeLayout in your outermost layout. You can set the image to display on the right and centre vertically.
<?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="wrap_content"
android:layout_height="144dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/date_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date_of_birth" />
<TextView
android:id="#+id/date_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/place_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/place_of_birth" />
<TextView
android:id="#+id/place_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/height_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/height" />
<TextView
android:id="#+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/blood_type_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/blood_type" />
<TextView
android:id="#+id/blood_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/member_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>

Heigth of ImageView

i want to add two imageViews in one layout, images i will set from galery (diferent size of image).Defaut images- all is ok. But when i set image from galery (image one)- a get a lot free space (image two)
2:
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exrcise name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_exrcise_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Image"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="#+id/radio_anime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="onRadioButtonClicked"
android:text="anime" />
<RadioButton
android:id="#+id/radio_static"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="static" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/iv_image_one"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="#drawable/btn_apply_oval_new" />
<ImageView
android:id="#+id/iv_image_two"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="#drawable/btn_apply" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_set_image_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/btn_set_image_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Muscle group"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner_muscle_group"
android:layout_width="wrap_content"
android:layout_height="45dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tecnique"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_tecnique"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_save_exercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE" />
<Button
android:id="#+id/test_anim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</ScrollView>
try
android:adjustViewBounds="true"
It worked for a similar problem i've had some time ago.
have you tried to set the height of both the problematic linearLayout and the imageView to wrap_content?
also, have you tried to set a weight (to 1) to the problematic linearLayout and then set its height to 0px ?

Using DatePicker and TimePicker in same layout

I'm trying to use one date picker and two time picker in the same layout, but only the first one in layout is being displayed. I'm sure something must be wring with my layout but haven't found the error yet.
layout.xml
<?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:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</LinearLayout>
try this one:
<?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:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
I just changed inner LinearLayouts height to wrap_content
You have three LinearLayout with match_parent in layout_width without a weight.
Try adding the next line to those LinearLayout's
android:layout_weight="1"

Categories

Resources