I am writing a chat application for learning Android programming in witch I will show the conversations between to users by a list. Any item of conversation list is a set of objects and a EditText with a bubble background. But when I show the conversation the EditText does not wrap it's content and the size of EditText is same in all rows of conversation.
Here is my conversation item's code:
<?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/llmain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables" >
<TextView
android:id="#+id/txtTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/chatdate"
android:gravity="center"
android:textAlignment="gravity"
android:textSize="8sp" />
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/llTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/chatme"
android:gravity="top|right"
android:paddingTop="7dp"
android:textAlignment="gravity"
android:visibility="visible" >
<ImageView
android:id="#+id/imgStatusTo"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:scaleType="fitXY"
android:src="#drawable/wait_ic" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgChatConversationToFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/ic_info" />
<TextView
android:id="#+id/txtChatConversationTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="60dp"
android:autoLink="web"
android:background="#color/chatme"
android:drawableBottom="#color/jigari"
android:drawableLeft="#color/jigari"
android:drawableRight="#color/jigari"
android:drawableTop="#color/jigari"
android:gravity="right|top"
android:inputType="none"
android:linksClickable="true"
android:paddingLeft="20dp"
android:paddingRight="40dp"
android:paddingTop="5dp"
android:scrollHorizontally="false"
android:scrollbars="none"
android:selectAllOnFocus="true"
android:singleLine="false"
android:textDirection="rtl" />
</LinearLayout>
<ImageView
android:id="#+id/imgChatConversationTo"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="bottom"
android:layout_marginBottom="5dp"
android:background="#color/gray"
android:contentDescription="#string/user_image"
android:scaleType="fitXY"
android:src="#drawable/ic_user_image" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/llFrom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/chatyou"
android:paddingTop="7dp"
android:visibility="visible" >
<ImageView
android:id="#+id/imgChatConversationFrom"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#color/gray"
android:contentDescription="#string/user_image"
android:scaleType="fitXY"
android:src="#drawable/ic_user_image" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgChatConversationFromFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/ic_info" />
<TextView
android:id="#+id/txtChatConversationFrom1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginRight="60dp"
android:autoLink="web"
android:background="#color/chatyou"
android:gravity="top|right"
android:inputType="none"
android:linksClickable="true"
android:paddingLeft="45dp"
android:paddingRight="20dp"
android:paddingTop="3dp"
android:scrollHorizontally="false"
android:scrollbars="none"
android:selectAllOnFocus="true"
android:singleLine="false"
android:textAlignment="gravity" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
My problem is on txtConversationFrom and txtConversationTo.
At the code I will hide items that not required there.
How I can force EditText to wrap text and resize to fit text size?
Correct me if I'm wrong but if you're talking about EditText you mean TextView right?
And your problem is that the text displayed in the TextViews won't linebreak if they are too large to fit in?
If yes you should probably add this:
android:inputType="textMultiLine"
to your TextViews.
And probably set the width of your LinearView which contains the txtChatConversationTo TextView to:
android:width="wrap_content"
Related
I have such xml:
on screen
I want to change the coordinates of layout "#+id/ifPopulate" every time when user will populate or remove items from listview (in other words, I want to have same distance between listview and layout #+id/ifPopulate").
And layout #+id/ifPopulate" don't have to be lower, than layout "#+id/buttons_at_the_bottom".
Here is my code. ListView's height need to be wrap_content, of course. I wrote "100 dp" just 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"
android:background="#color/blue_normal"
android:padding="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/ifSpinnerAddTextEdit"
android:orientation="vertical"
>
<ListView
android:id="#+id/lv2"
android:layout_width="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#color/white"
android:layout_marginBottom="5dp"
android:layout_height="100dp">
</ListView>
<LinearLayout
android:id="#+id/ifPopulate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/addItemNumTv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:layout_gravity="top"
android:text="#string/item_one" />
<EditText
android:id="#+id/addItemValEt1"
android:layout_width="0dp"
android:textColor="#color/grey"
android:paddingLeft="8dp"
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:layout_weight="1"
android:layout_gravity="top"
android:layout_height="40dp"
android:textCursorDrawable="#null"
android:inputType="textCapSentences" />
<Button
android:id="#+id/addItemValBut1"
android:layout_width="#dimen/lview_top_margin"
android:textColor="#color/white"
android:textSize="12sp"
android:layout_height="#dimen/lview_top_margin"
android:layout_gravity="top"
android:layout_marginLeft="10dp"
android:text="#string/ok" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:paddingBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:id="#+id/buttons_at_the_bottom">
<Button
android:id="#+id/saveCreateTemplateDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_marginRight="5dp"
android:onClick="getArrayProd"
android:textColor="#color/white"
android:text="#string/save"/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:onClick="getArrayProd"
android:textColor="#color/white"
android:text="#string/back"/>
</LinearLayout>
</LinearLayout>
I am using the following XML to draw a layout with heading, subheading, image and button. Image takes all remaining space but at the end I set it to visibility = View.GONE and my button is not aligned to bottom. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:baselineAligned="false">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/kasel"
android:id="#+id/txtChokeNext"
android:textSize="20sp"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_gravity="top"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/kaselDesc"
android:id="#+id/txtChokeNextDesc"
android:gravity="center"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_gravity="top"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/imgChokeDesc"
android:src="#drawable/kasel"
android:adjustViewBounds="true"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/firstAidNext"
android:id="#+id/buttonChokeNext"
android:layout_marginTop="10dp"
android:paddingLeft="10dp"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="20dp"
android:layout_gravity="bottom"
/>
</LinearLayout>
Thanks in forward
You could change your layout to RelativeLayout and set this parameter to your Button:
android:layout_alignParentBottom="true"
You should also add the android:layout_below="..." in the subheader and image to place them one after the other (replace ... with the id of the element that should be above the element you're editing)
solution of the your problem
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/kasel"
android:id="#+id/txtChokeNext"
android:textSize="20sp"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_gravity="top" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/kaselDesc"
android:id="#+id/txtChokeNextDesc"
android:gravity="center"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_gravity="top" />
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/imgChokeDesc"
android:src="#drawable/kasel"
android:adjustViewBounds="true"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:layout_weight="1" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/firstAidNext"
android:id="#+id/buttonChokeNext"
android:layout_marginTop="10dp"
android:paddingLeft="10dp"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="20dp"
android:layout_gravity="bottom" />
</LinearLayout>
I am stuck in one issue. I took edit text below list view just like chat application. Whenever i press enter key for new line list view does not change its position. I want listview should always display above edittext. Currently edittext displays behind the listview. When i scroll the listview then it displayed above edittext. Please help.
-->
<LinearLayout
android:id="#+id/linearLayout1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="#color/white"
android:paddingBottom="5dp">
<EditText
android:layout_weight="1"
android:id="#+id/chat_msg"
android:layout_height="wrap_content"
android:hint="#string/type_message"
android:paddingLeft="10dp"
android:inputType="textMultiLine"
android:layout_marginRight="5dp"
android:textColor="#color/Black"
android:layout_width="0dip">
<requestFocus></requestFocus>
</EditText>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/send_chat_icon"
android:layout_marginRight="5dp"
android:layout_gravity="bottom"
android:id="#+id/send_msg"></Button>
</LinearLayout>
<RelativeLayout
android:id="#+id/list_layout"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_above="#+id/linearLayout1"
android:background="#drawable/bg">
<FrameLayout
android:id="#+id/sub_fragment_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<LinearLayout
android:id="#+id/heading_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/signuphome_headingbg"
android:gravity="center_horizontal|bottom"
android:orientation="vertical" >
<TextView
android:id="#+id/follower"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/friends"
android:textColor="#color/white"
android:textSize="22sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/add_whisper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textColor="#color/white"
android:textSize="22sp"
android:layout_alignParentRight="true"
android:textStyle="bold"
android:visibility="gone"
android:text="+" />
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="#+id/follower_list"
android:layout_below="#+id/heading_layout"
android:layout_above="#+id/selected_contacts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/transparent" />
<ListView
android:id="#+id/follower_listView"
android:layout_below="#+id/heading_layout"
android:layout_above="#+id/selected_contacts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:visibility="gone" />
<Button
android:id="#+id/selected_contacts"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="Done"/>
</RelativeLayout>
here's a pseudo-XML that works for what you want. pretty basic stuff.
<RelativeLayout
<CommentArea align_BottomParent = true;/>
<ListView align_TopParent = true;
align_Above="commentArea"/>
/>
I am trying to have textviews overlay over imageviews. Something like this
Can someone help me with the code.
Wrap a TextView and ImageView into FrameLayout, put the TextView in FrameLayout after ImageView. Then, wrap the FrameLayout into RelativeLayout OR LinearLayout. Make some position setup (as per the needs).
<RelativeLayout>
<FrameLayout>
<ImageView />
<TextView />
</FrameLayout>
</RelativeLayout>
You can create a frame layout and within the frame layout keep an imageview and a linearlayout(with a translucent background and a textview).
The translucent color can be placed in the colors file as : #80000000
Here is a snippet :)
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:foregroundGravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivFullScreenAd"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="8dp"
android:src="#drawable/home_page_ad" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/translucent"
android:orientation="vertical" >
<TextView
android:id="#+id/detailTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:paddingLeft="10dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Please swipe up"
android:textColor="#color/white"
android:textIsSelectable="true"
android:textSize="20sp" />
</LinearLayout>
</FrameLayout>
I had the same problem and solved it using a custom gridView. You must apply this in getView.
Custom gridView XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_practitioner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/item_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:contentDescription="#string/contentDescriptionContent"
/>
<LinearLayout
android:id="#+id/layout_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:background="#CC515116"
android:visibility="gone"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:text="#string/text_enter_pass_password"
android:paddingBottom="7dp"
android:textSize="20sp"
/>
<EditText
android:id="#+id/edit_practitioner_pin"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center"
android:background="#drawable/edittext_shape"
android:ems="6"
android:gravity="center"
android:inputType="numberPassword"
android:maxLength="4"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:visibility="visible"
/>
<Button
android:id="#+id/pract_button"
android:layout_width="70dp"
android:layout_height="30dp"
android:background="#drawable/buton_shape"
android:layout_marginBottom="35dp"
android:text="#string/btn_ok"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="#bbffffff"
android:focusable="false"
android:focusableInTouchMode="false" >
<TextView android:id="#+id/item_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textColor="#color/text_black"
android:gravity="bottom|center"
android:textSize="20sp"
android:textAllCaps="true"
android:paddingBottom="0dp"
/>
<TextView
android:id="#+id/text_pratiotioner_group_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/sub_title_color"
android:visibility="visible"
android:gravity="bottom|center"
android:textAllCaps="true"
/>
</LinearLayout>
</FrameLayout>
Though an old question but should incase anyone is interested in the card view version of this question here you go...
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="5dp"
app:cardElevation="5dp"
android:layout_weight="0.5"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
android:clickable="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical"
android:layout_centerInParent="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="#89969F">
<ImageView
android:id="#+id/iv_overlay"
android:layout_width="196dp"
android:layout_height="196dp"
android:clickable="true"
android:src="#drawable/your_image"
android:layout_centerInParent="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#80000000"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="22sp"
android:textStyle="bold"
android:gravity="center_vertical"
android:text="Settings"
android:textColor="#color/white"
android:layout_gravity="center"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="8dp" />
</LinearLayout>
</FrameLayout>
</android.support.v7.widget.CardView>
Please modify the layout accordingly, If you want to accommodate the images on an imageview only, then you can drop the below layout in a relative one including an imageview too.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/your_image"
android:orientation="vertical" >
<TextView
android:id="#+id/bottom_textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
<!-- layout_gravity="supply accordingly" -->
android:gravity="center"/>
</LinearLayout>
i've a strange problem when i set android:layout_width="fill_parent" in my Spinner:
the clickable area is reduced to a line (red square) and only pressing on this line is possibile show the elements of the Spinner:
if i use android:layout_width="wrap_content" i obtain the correct area:
i would like the same thing using "fill_parent"
The elements of the Spinner are correctly visualized.. The only problem is clicking on the Spinner.
Which is the possible problem?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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:background="#040404"
android:gravity="center"
android:paddingTop="2dp"
android:weightSum="4" >
<TextView
android:id="#+id/mpp_movimento_lbl"
android:background="#drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="#drawable/freccia_verde"
android:gravity="center"
android:text="#string/Movimento"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="#+id/mpp_eccesso_lbl"
android:background="#drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="#drawable/freccia_rossa"
android:gravity="center"
android:text="#string/Eccesso"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="#+id/mpp_fermo_lbl"
android:background="#drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="#drawable/freccia_grigia"
android:gravity="center"
android:text="#string/Fermo"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="#+id/mpp_ripristina_lbl"
android:background="#drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="#drawable/ripristina_mappa_40x40"
android:gravity="center"
android:text="#string/Ripristina"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="17sp" />
</LinearLayout>
<TextView
android:id="#+id/mpp_automezzi_visualizzati_lbl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
android:gravity="center"
android:paddingTop="5dp"
android:text="#string/AutomezziVisualizzati"
android:textColor="#color/white"
android:textSize="17sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:paddingTop="5dp" >
<FrameLayout
android:id="#+id/mpp_spinner_frame_fly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/mpp_cerca_btn" >
<Spinner
android:id="#+id/mpp_spinner_spn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textSize="17sp" />
</FrameLayout>
<ImageButton
android:id="#+id/mpp_cerca_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#drawable/selector_white_btn"
android:contentDescription="#string/DescrizioneCerca"
android:gravity="center"
android:onClick="doCerca"
android:src="#drawable/cerca" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#040404"
android:gravity="center" >
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/mpp_mappa_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Try setting your Spinner's parent's height to match_parent. And also do you really need such layout? There is no need to place spinner in FrameLayout, try setting spinners's weight to 1 and replace RelativeLayout with LinearLayout