Reputation: 69
I working on UI design and the issue which i am facing here is I seated the ImageView at bottom of the Final Button and need that Image view to fill the remaining space at bottom of screen.I tried the different methods but if i set the ImageView inside the scrollview imageview height is taking matchparent.Hereby i am attaching my layout suggest me some ideas to resolve this issue.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/social_login"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?android:attr/actionBarSize"
android:orientation="vertical">
<ImageView
android:id="@+id/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/large_logo" />
<EditText
android:id="@+id/username"
android:layout_width="280dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:hint="@string/username_label"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColorHint="@color/signin_field_hint" />
<EditText
android:id="@+id/password"
android:layout_width="280dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:hint="@string/password_label"
android:inputType="textPassword"
android:singleLine="true"
android:textColorHint="@color/signin_field_hint" />
<Button
android:id="@+id/signin_btn"
style="@style/ButtonMain"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="@string/signIn_label" />
<TextView
android:id="@+id/forgot_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:gravity="center_horizontal"
android:text="@string/need_help_Signing_label"
android:textColor="@color/need_help_Signing"
android:textSize="@dimen/need_help_signing_label_size" />
<Button
android:id="@+id/create_account"
style="@style/ButtonMain"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:text="Final Button" />
<TextView
android:id="@+id/or"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="@string/or_label"
android:textColor="@color/or"
android:textSize="@dimen/or_label_size"
android:visibility="gone" />
<TextView
android:id="@+id/add_card_section_title"
style="@style/SectionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialer"
android:visibility="gone" />
//need this image view to fill the remaining space at bottom
<ImageView
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="10dp"
/>
</LinearLayout>
</ScrollView>
Upvotes: 0
Views: 205
Reputation: 707
Set your Imageview height to match_parent. It will definitely fill the entire bottom space.
<ImageView
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="10dp"
/>
Upvotes: 0
Reputation: 1172
This is a tricky one because you're using ScrollView
.
First, Add android:fillViewport="true"
to ScrollView
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:fillViewport="true">
...
</ScrollView>
Second, add a Space
view to fill the extra space above ImageView
. Repalce //need this image view to fill the remaining space at bottom
with following.
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
Upvotes: 1