Add scrollView and highlight on a Linear Layout in Android - android

I have Linearlayout that have have multiple linear layouts in which one of the main layout have a LinearLayout and Listview. LinearLayout contains multiple ImageView and TextView now I want to add ScrollView on this LinearLayout. But if I am adding the ScrollView my ListView got hidden and onClick of the ImageView I want to highlight that LinearLayout.
My XML is :
<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:id ="#+id/mainFilterLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/companyLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:layout_gravity="left"
android:adjustViewBounds="true"
android:background="#mipmap/ic_launcher" />
<View
android:clickable="true"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:gravity="right|center"
android:text="Clear" />
<Button
android:id="#+id/btnApply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:gravity="right|center"
android:text="Apply" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
//**I want to add scroll view on this linear layout**
<LinearLayout
android:id="#+id/categoryLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<LinearLayout
android:id="#+id/brandLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
//**Here on click of imageviwew i want set as selected for this linear layout**
<ImageView
android:id="#+id/mobbrand"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Brand" />
</LinearLayout>
<LinearLayout
android:id="#+id/colorLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobColor"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="COLOUR" />
</LinearLayout>
<LinearLayout
android:id="#+id/sizeLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobSize"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Size" />
</LinearLayout>
<LinearLayout
android:id="#+id/offerLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobOffers"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#mipmap/ic_launcher" />
<TextView
android:id="#+id/txtPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/othersLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobother"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#mipmap/ic_launcher" />
<TextView
android:id="#+id/txtOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="OTHER" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/subCategory"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5"
android:cacheColorHint="#android:color/transparent"
android:divider="#fff"
android:dividerHeight="1dp"
android:fadingEdge="none">
</ListView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

I hope this will work for u :
<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:id ="#+id/mainFilterLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/companyLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:layout_gravity="left"
android:adjustViewBounds="true"
android:background="#mipmap/ic_launcher" />
<View
android:clickable="true"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:gravity="right|center"
android:text="Clear" />
<Button
android:id="#+id/btnApply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:gravity="right|center"
android:text="Apply" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<LinearLayout
android:id="#+id/brandLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobbrand"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Brand" />
</LinearLayout>
<LinearLayout
android:id="#+id/colorLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobColor"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="COLOUR" />
</LinearLayout>
<LinearLayout
android:id="#+id/sizeLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobSize"
android:layout_width="90dp"
android:layout_height="50dp"
android:background="#mipmap/ic_launcher"
android:layout_gravity="center" />
<TextView
android:id="#+id/txtSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Size" />
</LinearLayout>
<LinearLayout
android:id="#+id/offerLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobOffers"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#mipmap/ic_launcher" />
<TextView
android:id="#+id/txtPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/othersLayout"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<ImageView
android:id="#+id/mobother"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#mipmap/ic_launcher" />
<TextView
android:id="#+id/txtOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="OTHER" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ListView
android:id="#+id/subCategory"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5"
android:cacheColorHint="#android:color/transparent"
android:divider="#fff"
android:dividerHeight="1dp"
android:fadingEdge="none">
</ListView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Simply do one thing cut the amount of code that you want in scrollview.... Now add scrollview in place of the code that u just "cut" ... now scrollview also have a child layout as linear layout.... in that linear layout make height to be wrap_content..... next place your code inside that linear layout... ListView outside the scrollayout...
[code]--------- Ctrl+X
replace with
<ScrollView>
<LinearLayout>
[code]-------- Ctrl+V
enter code here
</LinearLayout>
</ScrollView>
<ListView> -------- here add listview

Related

Implementing ScrollView Android?

I've got one question. I designed layout for movie details and it looks like this:
Now, I want to add movie description when user scroll down (so this layout stays the same, but when user scrolls it will display movie description).
Current layout is wrapped in LinearLayout (vertical).
How could I implement that scroll ? I tried to add scroll view as parent but it stretches this layout down...
Here is code by now ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:weightSum="10">
<ImageView
android:id="#+id/iv_backdrop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:scaleType="centerCrop" />
<LinearLayout
android:id="#+id/layout_favorite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-40dp"
android:gravity="right">
<RelativeLayout
android:layout_width="100dp"
android:layout_height="80dp"
android:layout_marginEnd="25dp">
<ImageView
android:id="#+id/iv_background_favorite"
android:layout_width="100dp"
android:layout_height="80dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:tint="#000000"
app:srcCompat="#drawable/ic_ellipse" />
<ImageView
android:id="#+id/iv_foreground_favorite"
android:layout_width="65dp"
android:layout_height="45dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
app:srcCompat="#drawable/ic_favorite_border_white_36px" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_short_desc"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="-20dp"
android:layout_weight="4">
<ImageView
android:id="#+id/iv_poster"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginStart="20dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/tv_title"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:textSize="19sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_tagline"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="italic" />
<TextView
android:id="#+id/tv_movie_released"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:text="12-12-2007(Released)"
android:textAlignment="viewStart"
android:textAllCaps="false"
android:textSize="16sp" />
<TextView
android:id="#+id/tv_movie_duration"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:text="Duration - 90 min"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/v_separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="20dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:weightSum="4">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:src="#drawable/hexagon" />
<TextView
android:id="#+id/tv_vote_average"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff"
android:textSize="16sp" />
<TextView
android:id="#+id/tv_number_votes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:adjustViewBounds="true"
android:src="#drawable/theatre" />
<TextView
android:id="#+id/tv_genre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:src="#drawable/circle_double_border" />
<TextView
android:id="#+id/tv_popularity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:text="Popularity"
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:src="#drawable/circle_double_border" />
<TextView
android:id="#+id/tv_language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:text="Language"
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
For Your Description only, simply use a NestedScrollView. Make sure that the height and width of NestedScrolllView are the ones that you originally used for your description TextView. Then Simply place the TextView in the NestedScrollView.
Read more about nestedScrollView here
https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html
http://www.devexchanges.info/2016/07/nested-scroll-views-in-android.html
Use something like this
<ScrollView> //Should be on top
<RelativeLayout> //Scroll View Contains only child view
<RelativeLayout>
//Paste your whatever so far created views.
</RelativeLayout>
<RelativeLayout>
//Place your Description view here
</RelativeLayout>
</RelativeLayout>
</ScrollView>

Two button one close to other at the bottom of RelativeLayout - Android

I am facing a problem with android layout.
I have a relative layout with a textview and an image overlapped and I would like to add two button at the bottom of the view, one close to other and that fill all the width of the view. Here below the manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:orientation="vertical"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_gravity="center"
android:longClickable="false"
android:layout_width="283dp"
android:layout_height="418dp"
android:src="#mipmap/bg_thand"
android:adjustViewBounds="false"
android:alpha="0.1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle">
<TextView
android:textSize="20sp"
android:gravity="center_horizontal"
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="#string/title_activity_record_accel_data"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/recording"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/back"/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
The layout appears in this way.
I would like that the two button appear in the same position but centered and that they fill equally the view in width.
Hope you will help me.
Can u modify your button layout impl. with the below sample and try.
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1">
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:id="#+id/back"
android:layout_weight="0.5"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"/>
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="0.5"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"/>
</LinearLayout>
Hi you can put buttons in linear layout and align parent bottom:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#mipmap/bg_thand" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="#string/title_activity_record_accel_data"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/recording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="#+id/back"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_toRightOf="#+id/back"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
check this it will help.
android:weight is what you may be looking for. Enclose the two buttons inside a linear layout and add android:weight =1 for both of them. An example would be :
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button android:id="#+id/button1"
...
android:layout_weight="1"/>
<View
android:id="#+id/space"
...
android:layout_weight=".1"/>
<Button android:id="#+id/button2"
...
android:layout_weight="1"/>
</LinearLayout>
You need to add spacer in in center bottom and align two button to that spacer like this :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
//Aligh Space in center with align to bottom
and set relation of two button to this spacer
<Space
android:layout_width="1px"
android:layout_height="1px"
android:layout_above="#+id/back"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/space"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="Back"
android:layout_gravity="center"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/accelText"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="Status"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_alignParentBottom="true"
android:layout_toStartOf="#+id/space"/>
</RelativeLayout>
Use this layout changes made with Button added inside Linear Layout and filled it with weight with android:gravity="bottom" and android:orientation="horizontal".
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#drawable/common_ic_googleplayservices" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/common_ic_googleplayservices"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="Progress"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="REcording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/back"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>

Unable to force images to be at bottom

<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.MainActivity"
android:weightSum="4"
android:orientation="vertical"
android:background="#EDEDED">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#db4437"
android:weightSum="2"
android:orientation="vertical"
>
<ImageView
android:id="#+id/imgHeader"
android:layout_height="80dp"
android:layout_width="200dp"
android:src="#drawable/cruise"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"/>
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Header"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:singleLine="true"
android:textAlignment="center"
android:layout_gravity="center_horizontal|center_vertical"
/>
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginTop="-30dp"
android:background="#android:color/white"
android:orientation="vertical"
android:weightSum="3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:elevation="30dp"
>
<EditText
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/textbox"
android:textColor="#android:color/black"
android:drawableStart="#drawable/user_male"
android:drawableLeft="#drawable/user_male"
android:adjustViewBounds="true"
android:maxHeight="10dp"
android:maxWidth="10dp"
android:scaleType="fitCenter"
android:hint="Email..." />
<EditText
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/textbox"
android:textColor="#android:color/black"
android:drawableStart="#drawable/user_male"
android:drawableLeft="#drawable/user_male"
android:adjustViewBounds="true"
android:maxHeight="20dp"
android:maxWidth="20dp"
android:hint="Password..." />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="horizontal"
android:background="#EDEDED"
android:weightSum="2"
>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#CCCCCC"
android:text="Forgot password?"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#EDEDED"
/>
<Button
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Login"
android:layout_marginRight="10dp"
android:background="#db4437"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:orientation="horizontal"
android:id="#id/bottom"
>
<ImageView
android:id="#+id/bus_ruta1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_one"
/>
<ImageView
android:id="#+id/bus_ruta2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_twi" />
<ImageView
android:id="#+id/bus_ruta3"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_three" />
</LinearLayout>
</LinearLayout>
Im using the following code The last linear layout contains three images and I want those images to be at the bottom of the screen but it is not being fixed at the bottom. How can I be able to sort this out?
try using a RelativeLayout instead to fill the whole screen and
the android:layout_alignParentBottom attribute
Possible dublicate of How to align views at the bottom of the screen?
try using RelativeLayout. Try this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EDEDED"
android:orientation="vertical"
android:weightSum="4"
tools:context="com.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#db4437"
android:orientation="vertical"
android:weightSum="2" >
<ImageView
android:id="#+id/imgHeader"
android:layout_width="200dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:src="#drawable/cruise" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:singleLine="true"
android:text="Header"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="-30dp"
android:layout_weight="1"
android:background="#android:color/white"
android:elevation="30dp"
android:orientation="vertical"
android:weightSum="3" >
<EditText
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:drawableLeft="#drawable/user_male"
android:drawableStart="#drawable/user_male"
android:hint="Email..."
android:maxHeight="10dp"
android:maxWidth="10dp"
android:scaleType="fitCenter"
android:textColor="#android:color/black" />
<EditText
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:drawableLeft="#drawable/user_male"
android:drawableStart="#drawable/user_male"
android:hint="Password..."
android:maxHeight="20dp"
android:maxWidth="20dp"
android:textColor="#android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#EDEDED"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"
android:text="Forgot password?"
android:textColor="#CCCCCC" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#EDEDED" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#db4437"
android:text="Login" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<ImageView
android:id="#+id/bus_ruta1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_one" />
<ImageView
android:id="#+id/bus_ruta2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_twi" />
<ImageView
android:id="#+id/bus_ruta3"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_three" />
</LinearLayout>
</RelativeLayout>
Here android:layout_alignParentBottom="true" is key paramater.
Happy Coding.

How to align ImageButtons in a layout evenly

I currently have 4 ImageButtons in a layout that takes only half of the screen height. I would like the ImageButtons to be placed evenly in the layout. Here is what I have:
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
This works, since here is the result:
The issue is, 1: I would like to add text under each button and I am not sure how that is going to work and 2: the white spots to the right and left of the ImageButtons are active, as if they were parts of the button. Is there a better way to do this?
You can do something like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/section1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 1"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 2"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img3"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 3"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img4"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 4"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
Result
and for second part of question you should set click listener on entire relative layout. for example for tap on first cell :-
xml
android:id="#+id/section1"
JAVA
findviewbyid(R.id.section1).setOnClickListener(...)
Another (and better) alternative is to work with TableLayout:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">
<TableRow
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn1"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn1"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 1"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn2"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn2"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 2"/>
</RelativeLayout>
</TableRow>
<TableRow
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn3"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn3"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 3"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn4"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn4"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 4"/>
</RelativeLayout>
</TableRow>
</TableLayout>

Embedded views layout_weight

In my app I have an actvity with following layot. And I have proplem with layout_weight. When I use weights with views that embedded in container, that also have weight parametr,wieghts of this doesn't work. Is it posible use embedded view weight in Android?
<?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/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10" >
<RelativeLayout
android:id="#+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="top"
android:layout_weight="1"
android:background="#color/header_color"
android:orientation="horizontal" >
<View
android:id="#+id/main_backView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#null" />
<ImageButton
android:id="#+id/menuBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/appNameText"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/appNameText"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:layout_marginLeft="30px"
android:background="#null"
android:scaleType="fitCenter"
android:src="#drawable/menu"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/mapClickText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="30px"
android:text="#string/map_text"
android:textColor="#android:color/white"
android:textSize="21sp" />
<TextView
android:id="#+id/appNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/app_name"
android:textColor="#android:color/white"
android:textSize="21sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="8" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="10" >
<RelativeLayout
android:id="#+id/imagePager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="top"
android:layout_weight="4"
android:background="#android:color/white" >
<mobi.esys.custom_components.AutoSwitchPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20px"
android:padding="2px" />
<TextView
android:id="#+id/bannerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="21sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/suggestIndicator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#color/suggestions_indicator_color" >
<TextView
android:id="#+id/suggAmount"
android:layout_width="60px"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="30px"
android:background="#drawable/circle"
android:gravity="center"
android:textColor="#color/suggestions_indicator_color"
android:textSize="21sp" />
<TextView
android:id="#+id/suggText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10px"
android:layout_marginTop="6px"
android:layout_toRightOf="#+id/suggAmount"
android:text="#string/sugg"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/suggVisitText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/suggAmount"
android:layout_marginLeft="10px"
android:layout_toRightOf="#+id/suggAmount"
android:textColor="#android:color/white"
android:textSize="12sp" />
<ImageButton
android:id="#+id/arrowBtn"
android:layout_width="30px"
android:layout_height="40px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="30px"
android:background="#null"
android:scaleType="fitXY"
android:src="#drawable/arrow" />
</RelativeLayout>
<GridLayout
android:id="#+id/whereTab"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:columnCount="2" >
</GridLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
<ImageView
android:id="#+id/logoImage"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="#drawable/logo"
tools:ignore="ContentDescription" />
</LinearLayout>
The weight mechanism distributes any remaining space in the parent linear layout after the first layout pass. A wrap_content layout doesn't have any remaining space. For what it's worth, a ScrollView doesn't work with match_parent height either.

Categories

Resources