I have this xml file.I can't understand why my second linearlayout which contains editText and callButton isn't looking right. It looks like this (the line with the part picture of phone) :
I have the layout_weights set to 1 in each of these views, editText and callButton, so the phone image should take up half the screen, right? Here's my code. I would like both views to take up the same width - and the editText shouldn't stretch when text is entered, as is currently happening. Thanks for any help.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity">
<ListView
android:id="#+id/ListView_2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1">
</ListView>
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
>
<!--android:adjustViewBounds="true"-->
<!-- we want the text to begin in the centre of the edittext view
that's what gravity does-->
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/editText"
android:inputType="phone"
android:gravity="center"
android:background="#d9d9d9"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/callButton"
android:src="#drawable/call"
android:clickable="true"
android:onClick="softkeyboardButton"
android:background="#ffa62b"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="4"
/>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/imageButton"
android:src="#drawable/softkeyboard"
android:clickable="true"
android:onClick="softkeyboardButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:background="#drawable/buttonstates"
/>
<View android:layout_height="fill_parent"
android:layout_width="2px"
android:background="#90909090"/>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/imageButton2"
android:src="#drawable/settingsicon"
android:background="#drawable/buttonstates"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Change your EditText and Call button with layout_width to "0dp" -
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/editText"
android:inputType="phone"
android:gravity="center"
android:background="#d9d9d9"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/callButton"
android:src="#drawable/call"
android:clickable="true"
android:onClick="softkeyboardButton"
android:background="#ffa62b"
android:layout_weight="1"
/>
Try setting the layout_width of the EditText and the ImageButton to 0dp.
I also recommend you to put the attribute android:scaleType="fitCenter" in the ImageButton so that the image fits inside the button and it doesn't look bigger like in the screenshot you provided.
Here is the XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity">
<ListView
android:id="#+id/ListView_2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1">
</ListView>
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
>
<!--android:adjustViewBounds="true"-->
<!-- we want the text to begin in the centre of the edittext view
that's what gravity does-->
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/editText"
android:inputType="phone"
android:gravity="center"
android:hint="Edit Text"
android:background="#d9d9d9"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/callButton"
android:src="#android:drawable/sym_call_incoming"
android:clickable="true"
android:scaleType="fitCenter"
android:onClick="softkeyboardButton"
android:background="#ffa62b"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="4"
/>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/imageButton"
android:src="#android:drawable/ic_menu_gallery"
android:clickable="true"
android:onClick="softkeyboardButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:background="#android:drawable/ic_menu_gallery"
/>
<View android:layout_height="fill_parent"
android:layout_width="2px"
android:background="#90909090"/>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/imageButton2"
android:src="#android:drawable/ic_menu_set_as"
android:background="#android:drawable/ic_menu_gallery"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
And this is how it looks:
I hope it helps!
For layout_weight to work, you should set either the layout_height or layout_weight to be 0dp on the widgets with weight.
From the looks of things I think you should spend some more time looking into how layout_weight works exactly
https://developer.android.com/guide/topics/ui/layout/linear.html#Weight
Related
I'm struggling to set an imageView and a textView in a single line inside LinearLayout. I tried with different ways but still I couldn't find a proper solution. Here is the code I used:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="40dp"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/icon_image"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="14sp"
android:textStyle="bold" >
</TextView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
</LinearLayout>
This is how it is appear :
What should I have to do to make correct this?
Its inside of a LinearLayout with a vertical orientation so naturally everything is stacked "vertically". Wrap them in a LinearLayout with a horizontal orientation
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="40dp"
tools:context=".MainActivity" >
<LinearLayout
.../>
<ImageView
android:id="#+id/icon_image"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="14sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
</LinearLayout>
By default, LinearLayout has a horizontal orientation so no need to supply that property in the child LinearLayout which wraps the two Views.
Use android:layout_gravity="center_vertical" for your textview
I suggest to use a RelativeLayout. That way you can add more items vertically as well.
You need to change the linearylayout's orientation. Just change android:orientation="vertical"
to
android:orientation="horizontal"
You can try enclosing your ImageViews and TextViews inside a TableLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="40dp"
tools:context=".MainActivity" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:id="#+id/icon_image"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="14sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
<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="wrap_content"
android:background="#color/gray"
android:gravity="fill_vertical"
tools:context=".TwitterHomeActivity" >
<RelativeLayout
android:id="#+id/top_line"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/settin_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:src="#drawable/settin_img" />
<ImageView
android:id="#+id/sonow_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/sonow" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="#+id/myviewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Checkbox"
android:layout_below="#+id/top_line"
android:background="#drawable/bg"
android:overScrollMode="never" >
</android.support.v4.view.ViewPager>
<RelativeLayout
android:id="#+id/Checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/unlike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/unlie_chkbox"
android:layout_alignParentLeft="true" />
<CheckBox
android:id="#+id/like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/like_chk_box_drable"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
I want like and dislike image fill copletely.I have added image.
here is some gap between them.
how remove it.
i am also want to show this in landscpe mode.it also fit in landscpe mode also.
please help me`
You should use a LinearLayout with weighted child views instead of a RelativeLayout.
The solution would look something like this:
...
<LinearLayout
android:id="#+id/Checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/unlike"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:weight="1"
android:button="#drawable/unlie_chkbox" />
<CheckBox
android:id="#+id/like"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#drawable/like_chk_box_drable" />
</LinearLayout>
...
(By the way, RelativeLayout doesn't have an android:orientation attribute.)
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>
So for my landscape layout of a page, I want to have a sort of horizontal layout. However, my FrameLayout including my ListView goes off the screen, even though it's set to android:layout_width="match_parent". Here's a screenshot of what I mean:
The blue line is the outline of where the FrameLayout is going, when it is set to match parent.
Here's my XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/contactlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="#drawable/brushed_metal_background_dark"
android:orientation="vertical"
tools:context=".ContactList" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/headerbackground"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:scaleType="center"
android:src="#drawable/homeheader7" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingRight="3sp"
android:text="#string/version"
android:textColor="#FFFFFF"
android:textStyle="italic" >
</TextView>
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:onClick="setOptions"
android:src="#drawable/menu" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<ImageButton
android:id="#+id/report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:gravity="left"
android:onClick="report"
android:scaleType="center"
android:src="#drawable/submit_report" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:scaleType="center"
android:src="#drawable/divider_ver" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:scaleType="center"
android:src="#drawable/schoolfeed2" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:background="#drawable/background_overlay_dark"
android:duplicateParentState="false"
android:fadingEdge="horizontal"
android:paddingBottom="9dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:paddingTop="7dp" >
<ListView
android:id="#+id/schoolFeed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="2dp"
android:footerDividersEnabled="false"
android:headerDividersEnabled="true"
android:scrollbarDefaultDelayBeforeFade="50000"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
android:scrollbarTrackVertical="#drawable/scrollbar_vertical_track" >
</ListView>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Any help is appreciated! Thanks,
I would recommend you that, instead of using match_parent, use wrap_content, becuase, actually, whats happening is that the framelayout has the same width of the screen, so, as it isn't at the left of the screen, it goes off.
I have 3 imageviews but since they overlap i wont make them clickable, i want make buttons on top of each imageview(but smaller).
I know in RelativeLayout there is easy way out using align_baseline but it is very important that i use LinearLayout for these images because they use layout_weight
And its important that button is connected with imageview, not just appearing on top of it
And here is my code it might help
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/twitter"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:weightSum="3"
android:layout_marginBottom="25dp"
android:layout_alignParentTop="true" >
<ImageView
android:id="#+id/imgDis"
android:layout_weight="1"
android:layout_width="300dp"
android:layout_height="120dp"
android:layout_marginBottom="-20dp"
android:background="#drawable/img1" />
<ImageView
android:id="#+id/imgCal"
android:layout_weight="1"
android:layout_width="300dp"
android:layout_height="120dp"
android:layout_gravity="right"
android:layout_marginBottom="-25dp"
android:background="#drawable/img2"
android:paddingLeft="25dp" />
<ImageView
android:id="#+id/imgDe"
android:layout_weight="1"
android:layout_width="300dp"
android:layout_height="120dp"
android:background="#drawable/img3" />
</LinearLayout>
...
</RelativeLayout>
put the image in another linear layout vertical and place that layout inside your mainlayout and give the wieght to this linearlayout instead of the image
Here is your answer, while using weight you must define 0dp to height/width to view as per case.
You want Button on every Imageview something like below?
I tried, check below xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="25dp"
android:orientation="vertical"
android:weightSum="6" >
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="0.5"
android:text="button first" />
<ImageView
android:id="#+id/imgDis"
android:layout_width="300dp"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1.5"
android:background="#drawable/logo" />
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="0.5"
android:text="button first" />
<ImageView
android:id="#+id/imgCal"
android:layout_width="300dp"
android:layout_height="0dp"
android:layout_gravity="right"
android:layout_marginTop="5dp"
android:layout_weight="1.5"
android:background="#drawable/logo"
android:paddingLeft="25dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="0.5"
android:text="button first" />
<ImageView
android:id="#+id/imgDe"
android:layout_width="300dp"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1.5"
android:background="#drawable/logo" />
</LinearLayout>
</RelativeLayout>