I'm working on a project where I have a screen that contains some elements separated by different layout types. All of these elements needed to be grouped within a single LinearLayout
so that I could "envelop" them in a ScrollView
. The problem is that one of these layouts is simply 'throwing' out another's view, taking up all the available space. The result is this:
Noticeinthepartinbluethathasalayout(inthiscase,aRelativeLayout
)crushedoutofthescreen.Thislayoutshouldbefixedatthebottomofthescreen,butifIchangetheLinearLayoutfilltypeimmediatelyaboveit,thisistheresult:
TheCANCELandSAVEbuttonsshouldbeattachedtothebottomofthescreen.ThisistheXMLusedinthelayout:
<?xmlversion="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_new_color"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clipToPadding="false"
android:fillViewport="true"
android:scrollbarStyle="insideOverlay"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.ions.colorcodes.activities.NewColorActivity"
tools:showIn="@layout/activity_new_color">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/input_color_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_color_name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_code"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/input_color_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_color_code" />
</android.support.design.widget.TextInputLayout>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="16dp" />
<TextView
android:id="@+id/info_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/info_preview" />
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="8dp" />
<LinearLayout
android:id="@+id/card_preview_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.CardView
android:id="@+id/card_preview"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/card_margin"
android:elevation="4dp"
app:cardCornerRadius="@dimen/card_album_radius">
<RelativeLayout
android:id="@+id/preview_card"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/new_color_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/new_color_preview"
android:paddingLeft="@dimen/album_title_padding"
android:paddingRight="@dimen/album_title_padding"
android:paddingTop="@dimen/album_title_padding"
android:textStyle="bold" />
<TextView
android:id="@+id/new_color_hex_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/new_color_name"
android:paddingBottom="@dimen/songs_count_padding_bottom"
android:paddingLeft="@dimen/album_title_padding"
android:paddingRight="@dimen/album_title_padding" />
<ImageView
android:id="@+id/new_color_preview"
android:layout_width="match_parent"
android:layout_height="128dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:clickable="true"
android:scaleType="fitXY" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/preview_button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal">
<Button
android:id="@+id/btn_cancel_new_color"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_cancel" />
<Button
android:id="@+id/btn_save_new_color"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_save" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
Where am I going wrong? I've been looking for solutions for a long time and I can not find anything to help me.