Button position can't be placed correctly - android

I am developing an android app but buttons can't be placed correct position. I use layout_width="match_parent" but it is going to the right side. layout_gravity= "center" is also same.
<LinearLayout
android:layout_width="368dp"
android:layout_height="495dp"
android:orientation="vertical"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:id="#+id/imgView"
/>
<mehdi.sakout.fancybuttons.FancyButton
android:id="#+id/btn_spotify"
android:layout_width="match_parent"
android:layout_height="45dp"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
fancy:fb_textSize="20dp"
android:layout_gravity="center_vertical"
fancy:fb_borderColor="#FFFFFF"
fancy:fb_iconResource="#drawable/ic_image_black_24dp"
fancy:fb_borderWidth="1dp"
fancy:fb_defaultColor="#6495ED"
fancy:fb_focusColor="#9bd823"
fancy:fb_iconPosition="left"
fancy:fb_radius="10dp"
fancy:fb_text="LOAD PICTURE"
fancy:fb_textColor="#FFFFFF" />
<ru.dimorinny.floatingtextbutton.FloatingTextButton
android:id="#+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:floating_background_color="#color/colorPrimary"
app:floating_icon="#drawable/ic_image_black_24dp"
app:floating_title="Load Picture"
app:floating_title_color="#android:color/white" />
<Button
android:layout_below="#+id/buttonLoadPicture"
android:foregroundGravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PROCESS"
android:scaleType="centerInside"
android:id="#+id/btn_process"
/>
<Button
android:layout_below="#+id/btn_process"
android:foregroundGravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Next Page"
android:scaleType="centerInside"
android:id="#+id/btn_next"
/>
<TextView
android:layout_below="#+id/btn_process"
android:foregroundGravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="NO TEXT"
android:textSize="18sp"
android:scaleType="centerInside"
android:id="#+id/textview_result"
/>
</LinearLayout>
So how can I fix it? I want to place the button correct position & it will be same for all android phone.

Change the width of Main parent layout Linearlayout width to Match_Parent and remove tools:layout_editor_absoluteY="8dp" and tools:layout_editor_absoluteX="8dp"
Edit :
As this LinearLayout is under ConstraintLayout. You need to assign app:layout_constraintLeft_toLeftOf and
app:layout_constraintRight_toRightOf property.
<LinearLayout
android:id="#+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

You're giving a fixed height and width for your parent LinearLayout. Either try
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
or go with a relativelayout.

Set Parent Linear layout width to android:layout_width="match_parent" and android:gravity="center_horizontal"
<LinearLayout
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp"
android:layout_width="match_parent"
android:layout_height="495dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside" />
<mehdi.sakout.fancybuttons.FancyButton
android:id="#+id/btn_spotify"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
fancy:fb_borderColor="#FFFFFF"
fancy:fb_borderWidth="1dp"
fancy:fb_defaultColor="#6495ED"
fancy:fb_focusColor="#9bd823"
fancy:fb_iconPosition="left"
fancy:fb_iconResource="#drawable/ic_image_black_24dp"
fancy:fb_radius="10dp"
fancy:fb_text="LOAD PICTURE"
fancy:fb_textColor="#FFFFFF"
fancy:fb_textSize="20dp" />
<ru.dimorinny.floatingtextbutton.FloatingTextButton
android:id="#+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:floating_background_color="#color/colorPrimary"
app:floating_icon="#drawable/ic_image_black_24dp"
app:floating_title="Load Picture"
app:floating_title_color="#android:color/white" />
<Button
android:id="#+id/btn_process"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/buttonLoadPicture"
android:foregroundGravity="center_horizontal"
android:scaleType="centerInside"
android:text="PROCESS" />
<Button
android:id="#+id/btn_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_process"
android:foregroundGravity="center_horizontal"
android:scaleType="centerInside"
android:text="Next Page" />
<TextView
android:id="#+id/textview_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_process"
android:foregroundGravity="center_horizontal"
android:scaleType="centerInside"
android:text="NO TEXT"
android:textSize="18sp" />
</LinearLayout>

if your LinearLayout is under ConstraintLayout use this
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"

Related

layout_weight doesn't behave as expected

In my application I want to position elements under a card view, using layout_weight with values .3 and .7. However It seems that, the space it takes is dependant on the text lengh that my card view holds. Here's the example code:
First card view:
<androidx.cardview.widget.CardView
android:id="#+id/card_view_terminal"
android:layout_width="match_parent"
android:layout_height="118dp"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="5dp"
android:layout_marginHorizontal="15dp"
card_view:cardElevation="4dp"
android:layout_marginTop="22dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="14dp"
android:gravity="center_vertical"
android:weightSum="1">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="69dp"
android:layout_height="60dp"
android:src="#drawable/use_card_reader"
android:scaleType="centerInside"
android:layout_weight=".3"
android:background="#color/colorAccent"
/>
<LinearLayout
android:background="#87ceeb"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read Card"
android:textColor="#color/navy"
android:textSize="17sp"
android:textStyle="bold"
android:textAlignment="center"
card_view:fontFamily="#font/assistant_semibold" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here to read the card"
android:textSize="14sp"
android:fontFamily="#font/assistant"
android:textColor="#color/navy"
android:textAlignment="textStart"
/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
Second Card view:
[![<androidx.cardview.widget.CardView
android:id="#+id/manual_entry"
android:layout_width="match_parent"
android:layout_height="118dp"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="5dp"
android:layout_marginHorizontal="15dp"
card_view:cardElevation="4dp"
android:layout_marginTop="22dp"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="14dp"
android:weightSum="1"
android:gravity="center_vertical"
android:layout_marginEnd="14dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="69dp"
android:layout_height="54dp"
android:src="#drawable/manual_fill"
android:scaleType="centerInside"
android:layout_weight=".3"
android:background="#color/colorAccent"
/>
<LinearLayout
android:background="#87ceeb"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read Paper"
android:textColor="#color/navy"
android:textSize="17sp"
android:textStyle="bold"
android:textAlignment="center"
card_view:fontFamily="#font/assistant_semibold" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some long explanation text"
android:textSize="14sp"
android:fontFamily="#font/assistant"
android:textColor="#color/navy"
android:textAlignment="textStart"
/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
Here's the attached image:
As you can see, the second card has an image that is shorter in length, because the text on the right side is longer. How can I fix this that the views will take exactly .3 and .7 of the space, regardless of the text that comes after?
You need to take static layout height.
<androidx.cardview.widget.CardView
android:id="#+id/card_view_terminal"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="5dp"
android:layout_marginHorizontal="15dp"
card_view:cardElevation="4dp"
android:layout_marginTop="22dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="118dp"
android:layout_marginHorizontal="14dp"
android:gravity="center_vertical"
android:weightSum="1">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="69dp"
android:layout_height="60dp"
android:src="#drawable/use_card_reader"
android:scaleType="centerInside"
android:layout_weight=".3"
android:background="#color/colorAccent"
/>
<LinearLayout
android:background="#87ceeb"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read Card"
android:textColor="#color/navy"
android:textSize="17sp"
android:textStyle="bold"
android:textAlignment="center"
card_view:fontFamily="#font/assistant_semibold" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here to read the card"
android:textSize="14sp"
android:fontFamily="#font/assistant"
android:textColor="#color/navy"
android:textAlignment="textStart"
/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
layout_weight in LinerLayout to make it work as expected u should take care of this:
if the LinerLayout orientation is vertical then the child's height should be 0dp and the layout_weight value will determine the height of the child
if the LinerLayout orientation is horizontal then the child's width should be 0dp and the layout_weight value will determine the width of the child
so in your code the child should look like this:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="14dp"
android:weightSum="1"
android:gravity="center_vertical"
android:layout_marginEnd="14dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="odp"
android:layout_height="54dp"
android:src="#drawable/manual_fill"
android:scaleType="centerInside"
android:layout_weight=".3"
android:background="#color/colorAccent"
/>
<LinearLayout
android:background="#87ceeb"
android:layout_weight="0.7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read Paper"
android:textColor="#color/navy"
android:textSize="17sp"
android:textStyle="bold"
android:textAlignment="center"
card_view:fontFamily="#font/assistant_semibold" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some long explanation text"
android:textSize="14sp"
android:fontFamily="#font/assistant"
android:textColor="#color/navy"
android:textAlignment="textStart"
/>
</LinearLayout>
</LinearLayout>

How to align TextView + RecyclerView at screen bottom within ScrollView?

I have the next structure of XML file in my Fragment. I have an issue with RelativeLayout 3 (id=referralsContainer). It consist of textView (id=inviteText) + RecyclerView (id=rv_referrals). I need to show textView at the bottom of screen with any resolution. And after that textView must be RecyclerView with elements (when user will scroll down). I tried to do something like this in method, when all elements of recyclerview loaded, but recyclerview is replaced in different positions by Y axe from time to time, I can't understand how to correctly place that textview at the bottom of the scrren. And also ScrollView cuts several items of recyclerView. Does anybody can help with this? All positions in debugger looks right. Code+xml is below image. Thanks.
this.dataSourceListForAdapter.addAll(incomeListOfItemsFromServer);
recyclerView.setY(scrollView.getBottom() - textView.getHeight());
recyclerView.setY(coordinatorView.getBottom() - textView.getHeight());
adapter.notifyDataSetChanged();
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/invite_friends_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/invite_friends_content_part"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:visibility="visible">
<RelativeLayout
android:id="#+id/invite_friends_container"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_alignParentTop="true"
android:background="#color/re_black_light_new">
<TextView
android:id="#+id/invite_friends_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/invite_friends_button_container"
android:gravity="center"
android:paddingEnd="40dp"
android:paddingStart="40dp"
android:textColor="#color/white"
android:textSize="16sp"
tools:text="#string/friends_invite_message" />
<RelativeLayout
android:id="#+id/invite_friends_button_container"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true">
<View
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginTop="2dp"
android:background="#drawable/combined_shape_white" />
<View
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:background="#color/white" />
<android.support.v7.widget.CardView
android:id="#+id/invite_friends_button_invite"
android:layout_width="147dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
card_view:cardBackgroundColor="#color/white"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true">
<TextView
android:id="#+id/invite_friends_button_invite_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/yellow_button_selector"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="#string/friends_invite"
android:textAllCaps="true"
android:textColor="#color/re_black_light_new"
android:textSize="14sp" />
</android.support.v7.widget.CardView>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/copy_choice_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_container"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:text="#string/copy_link_text"
android:textColor="#color/re_gray_new" />
<RelativeLayout
android:id="#+id/invite_friends_referal_link_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/copy_choice_label"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="16dp"
android:background="#drawable/rectangle_gray">
<TextView
android:id="#+id/invite_friends_referal_link_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:padding="7dp"
android:textColor="#color/re_black_light"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/invite_friends_full_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_referal_link_button"
android:layout_marginTop="32dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginStart="24dp"
android:layout_toLeftOf="#+id/invite_friends_container_central"
android:gravity="center_vertical">
<TextView
android:id="#+id/invite_friends_text_friends"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="#string/friends_invite_friends"
android:textColor="#color/re_black_light_new"
android:textSize="12sp" />
<TextView
android:id="#+id/invite_friends_friends_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_text_friends"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-medium"
android:textColor="#color/re_black_light_new"
android:textSize="24sp"
tools:text="4" />
<View
android:id="#+id/invite_friends_divider_horizontal"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/invite_friends_friends_count"
android:layout_marginTop="8dp"
android:background="#drawable/dash_horizontal_gray"
android:layerType="software" />
<TextView
android:id="#+id/invite_friends_text_orders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/invite_friends_divider_horizontal"
android:layout_marginTop="14dp"
android:fontFamily="sans-serif-medium"
android:text="#string/friends_invite_orders"
android:textColor="#color/re_black_light_new"
android:textSize="12sp" />
<TextView
android:id="#+id/invite_friends_orders_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_text_orders"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-medium"
android:textColor="#color/re_black_light_new"
android:textSize="24sp"
tools:text="32" />
</RelativeLayout>
<View
android:id="#+id/invite_friends_container_central"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_centerInParent="true"
android:background="#drawable/dotted_line"
android:layerType="software" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/invite_friends_container_central">
<TextView
android:id="#+id/invite_friends_income_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="6dp"
android:fontFamily="sans-serif-medium"
android:text="#string/friends_invite_income"
android:textColor="#color/re_black_light_new"
android:textSize="12sp" />
<LinearLayout
android:id="#+id/invite_friends_income_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_income_text"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/invite_friends_income_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:fontFamily="sans-serif-medium"
android:lines="1"
android:maxLines="1"
android:textColor="#color/re_black_light_new"
android:textSize="24sp"
tools:text="1488.77" />
<TextView
android:id="#+id/invite_friends_income_currency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:fontFamily="sans-serif-medium"
android:lines="1"
android:maxLines="1"
android:textColor="#color/re_black_light_new"
android:textSize="12sp"
tools:text="руб." />
</LinearLayout>
<View
android:id="#+id/invite_friends_divider_horizontal_2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/invite_friends_income_container"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/dash_horizontal_gray"
android:layerType="software" />
<TextView
android:id="#+id/invite_friends_text_income_pending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_divider_horizontal_2"
android:layout_marginStart="6dp"
android:layout_marginTop="14dp"
android:fontFamily="sans-serif-medium"
android:text="#string/friends_invite_income_pending"
android:textColor="#color/re_black_light"
android:textSize="12sp" />
<LinearLayout
android:id="#+id/invite_friends_text_income_pending_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/invite_friends_text_income_pending"
android:layout_marginStart="6dp"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/invite_friends_text_income_pending_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:textColor="#color/re_gray_new"
android:textSize="24sp"
tools:text="0" />
<TextView
android:id="#+id/invite_friends_text_income_pending_count_currency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:fontFamily="sans-serif-medium"
android:lines="1"
android:maxLines="1"
android:textColor="#color/re_gray_new"
android:textSize="12sp"
tools:text="руб."/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/referralsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/invite_friends_content_part"
android:visibility="gone"
android:orientation="vertical">
<TextView
android:id="#+id/inviteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:fontFamily="sans-serif-medium"
android:text="Вы уже пригласили:"
android:textColor="#color/re_black_light_new"
android:textSize="20sp"
android:textStyle="normal" />
<ImageView
android:id="#+id/scrollMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/inviteText"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:src="#drawable/ic_scroll_more" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_referrals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scrollMore"
android:scrollbars="vertical" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/invite_friends_error_part"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="#+id/error_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:scaleType="fitCenter"
android:src="#drawable/lost_connection_holder" />
<TextView
android:id="#+id/error_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/error_image"
android:layout_marginBottom="60dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/no_connection_message"
android:textColor="#color/black_tr_38"
android:textSize="19sp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
ScrollView is not purposed for sub-child layouts aligned to the bottom of screen as its direct child doesn't know where the bottom is. From your question is not clear how do you need (want) to scroll bottom part.
If it is ok to scroll by dragging bottom part (RelativeLayout 3) it is better to use BottomSheetBehaviour in Coordinatorlayout for this layout.
If not then just put RelativeLayout 3 under (below) SwipeRefreshLayout and handle ScrollView scrollChanged events to animate scrolling of bottom layout if you need or just show/hide this bottom layout.
Don't forget that on small resolutions layout aligned to the bottom will cover the content of ScrollView and user won't be able to scroll top layout.

ImageView as background being pushed up by opening keyboard

As I'm using png as a background for my View I didn't want it to stretch in a weird way. So I put an ImageView inside RelativeLayout and set its parametrs to match parent.
The problem appears when I click on a edittext and keyboard is opening. android:windowSoftInputMode="adjustResize" and keyboard pushes every view inside relative layout up, so my background image moves to. Do you know how to fix this?
Basically I want to adjust the view but not background image.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/login_relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:hapticFeedbackEnabled="false"
tools:context="com.example.radzik.recipes.activity.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/background_activity_login" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:gravity="center_horizontal">
<ProgressBar
android:id="#+id/progress_bar_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<LinearLayout
android:id="#+id/login_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="#+id/progress_bar_login"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_email_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="EMAIL"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_email_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:hint="example#gmail.com"
android:inputType="textEmailAddress"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white" />
<TextView
android:id="#+id/text_view_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="PASSWORD"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/text_view_password"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:inputType="textPassword"
android:paddingBottom="5dp"
android:paddingTop="0dp"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white"
android:textSize="30sp" />
<Space
android:layout_width="1dp"
android:layout_height="20dp" />
<Button
android:id="#+id/button_sign_in"
style="?android:textAppearanceSmall"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_sign_in"
android:onClick="onLoginClicked"
android:padding="10dp"
android:text="Log In"
android:textColor="#android:color/white"
android:textStyle="bold" />
<Space
android:layout_width="1dp"
android:layout_height="35dp" />
<!--<Button-->
<!--android:id="#+id/button_facebook_sign_in"-->
<!--style="?android:textAppearanceSmall"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="fill_parent"-->
<!--android:background="#color/colorPrimaryDark"-->
<!--android:onClick="onFacebookLogInClicked"-->
<!--android:padding="10dp"-->
<!--android:layout_marginLeft="10dp"-->
<!--android:layout_marginRight="10dp"-->
<!--android:text="Login with Facebook"-->
<!--android:textStyle="bold"-->
<!--android:textColor="#color/colorText"/>-->
<com.facebook.login.widget.LoginButton
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textStyle="bold"
/>
<!-- <Button
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_facebook_log_in"
android:drawableLeft="#drawable/facebook_white_logo_custom_1"
android:paddingLeft="10dp"
android:paddingRight="36dp"
android:text="Facebook"
android:textColor="#android:color/white"
android:textStyle="bold" /> -->
<Space
android:layout_width="1dp"
android:layout_height="10dp" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
app:srcCompat="#drawable/login_bottom_coloured_line" />
<Button
android:id="#+id/button_sign_up"
style="?android:textAppearanceSmall"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#040C12"
android:onClick="onSignUpClicked"
android:padding="10dp"
android:text="SIGN UP"
android:textColor="#android:color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Background image:
background image
Try this:
Put you ImageView inside scrollview.
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="#drawable/background_activity_login"/>
</ScrollView>
And in java set scrollview enabled false in onCreate method like below:
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView);
scrollView.setEnabled(false);
Try not to add background in scroll view add another layout for background after scrollview it work for me

Layout issue in high resolution device android

I want to make below listview row file
So I have set layout row file code as below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/rel_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5dp"
android:background="#drawable/rect_white">
<LinearLayout
android:id="#+id/ll_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:id="#+id/ll_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="70">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="#+id/ckh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/margin_5dp" />
<customtext.BoldText
android:id="#+id/task_title"
style="#style/NormalTextView"
android:layout_marginLeft="#dimen/margin_2dp"
android:layout_marginRight="#dimen/margin_5dp"
android:layout_marginTop="#dimen/margin_10dp"
android:layout_toRightOf="#+id/ckh"
android:singleLine="false"
android:text="Title"
android:textColor="#android:color/black"
android:textSize="#dimen/text_11" />
<customtext.RegularText
android:id="#+id/task_assign"
style="#style/NormalTextView"
android:layout_alignLeft="#+id/task_title"
android:layout_below="#+id/task_title"
android:layout_marginTop="#dimen/margin_2dp"
android:layout_toRightOf="#+id/ckh"
android:background="#drawable/rect_full"
android:padding="#dimen/margin_2dp"
android:text="Title"
android:textColor="#android:color/white"
android:textSize="#dimen/text_8" />
<customtext.RegularText
android:id="#+id/task_date"
style="#style/NormalTextView"
android:layout_alignLeft="#+id/task_assign"
android:layout_below="#+id/task_assign"
android:paddingBottom="#dimen/margin_5dp"
android:text="Title"
android:layout_marginTop="#dimen/margin_2dp"
android:textColor="#color/dark_gray"
android:textSize="#dimen/text_10" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:layout_marginRight="1.5dp"
android:layout_marginTop="1.5dp"
android:layout_weight="30"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
When I run this in normal device like 480x800 than it will give output like below image
And when I run this in high resolution device like 1080x1920 with (320dpi)(Sony xperia z Ultra) at that time i give below output
So any idea how can I maintain this layout in very high resolution devices?
I have updated your code with images and variables in one of my projects. I recommend you to change the LinearLayout with the weight sum of 100 to a relative layout and put the item you want to fix the size to align parent right. Here is an example which work. You can fix the relativelayout root height. Hope it help
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/rel_items"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_margin="5dp"
android:background="#android:color/white">
<RelativeLayout
android:id="#+id/ll_main"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:layout_marginRight="1.5dp"
android:layout_alignParentRight="true"
android:padding="10dp"
android:layout_marginTop="1.5dp"
android:background="#drawable/button_connexion"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginRight="20dp"
android:src="#drawable/statut_presence_jaune" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/statut_presence_vert" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="#+id/ckh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp" />
<TextView
android:id="#+id/task_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="#+id/ckh"
android:singleLine="false"
android:text="Title"
android:textColor="#android:color/black"
android:textSize="11sp" />
<TextView
android:id="#+id/task_assign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/task_title"
android:layout_below="#+id/task_title"
android:layout_marginTop="2dp"
android:layout_toRightOf="#+id/ckh"
android:background="#android:color/holo_blue_bright"
android:padding="2dp"
android:text="Title"
android:textColor="#android:color/white"
android:textSize="8sp" />
<TextView
android:id="#+id/task_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/task_assign"
android:layout_below="#+id/task_assign"
android:paddingBottom="5dp"
android:text="Title"
android:layout_marginTop="2dp"
android:textColor="#android:color/darker_gray"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
change weight for your view with id
android:id="#+id/ll_left"
to 1. And delete your view with id
android:id="#+id/ll_right"
and replace it with following line of code:
<LinearLayout
android:id="#+id/ll_img_edit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center">
<ImageView
android:id="#+id/img_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/edit" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_img_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center">
<ImageView
android:id="#+id/img_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/delete" />
</LinearLayout>
in this you can change margin value as per your requirement.
In your LinearLayout which contains Imageviews delete and edit.You have specified right margin to them remove that and weight sum here.
Just change your second layout by below,
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:layout_marginRight="1.5dp"
android:layout_marginTop="1.5dp"
android:layout_weight="30"
android:background="#android:color/transparent"
android:gravity="center|right">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete" />
</LinearLayout>
</LinearLayout>
Use weightSum property with second Layout.
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:weighSum = "1"
android:layout_marginRight="1.5dp"
android:layout_marginTop="1.5dp"
android:layout_weight="30"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit" />
<ImageView
android:id="#+id/img_delete"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete" />
</LinearLayout>
just add both ImageView weight property like below way. So it will take equal width to both ImageView.
<ImageView
android:id="#+id/img_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit"
android:layout_weight="1" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete"
android:layout_weight="1" />
</LinearLayout>
instead of this
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:layout_marginRight="1.5dp"
android:layout_marginTop="1.5dp"
android:layout_weight="30"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete" />
</LinearLayout>
use this for the image Linear layout your problem will be solved...
<LinearLayout
android:id="#+id/ll_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1.5dp"
android:layout_marginRight="1.5dp"
android:layout_marginTop="1.5dp"
android:layout_weight="30"
android:background="#drawable/rect_task_edit_delete"
android:gravity="center|right">
<ImageView
android:id="#+id/img_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginRight="#dimen/margin_20dp"
android:src="#drawable/edit" />
<ImageView
android:id="#+id/img_delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginRight="#dimen/margin_10dp"
android:src="#drawable/delete" />
</LinearLayout>
Note:-This issue due to you make it imageView wrap-content and Linear Layout with weight so Linear layout adjust due to its weight But imageView is wrap content.So it vary device to device .....

Picture not aligning top?

So in my program i have a layout implemented in which i want the image to alignTop of the parent. I used to exact same layout code for another activity (with minor changes) and it works perfectly but when using it in this activity it does not. My image still aligns to the center fo the view. Here is the layout xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/darkGray"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.intellidev.fuzionvapor.HomeDetails"
tools:showIn="#layout/activity_home_details">
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:scaleType="fitCenter" />
<TextView
android:id="#+id/homeDetailsActivityTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/homeDetailsActivityImage"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/homeDetailsActivityPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/homeDetailsActivityImage"
android:textColor="#color/fuzionRed"
android:textSize="20sp"
android:textStyle="bold" />
<View
android:id="#+id/homeDetailsActivityRuler"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="#+id/homeDetailsActivityTitle"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#color/white" />
<TextView
android:id="#+id/homeDetailsActivityDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/homeDetailsActivityRuler"
android:textColor="#color/white"
android:textSize="15sp" />
<LinearLayout
android:id="#+id/homeDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/homeDetailsActivityButton"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/homeDetailsActivitySizeSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="1dp"
android:layout_weight="1"
app:ms_arrowColor="#color/fuzionRed"
app:ms_arrowSize="16dp"
app:ms_baseColor="#color/fuzionRed"
app:ms_enableFloatingLabel="true"
app:ms_floatingLabelColor="#color/fuzionRed"
app:ms_floatingLabelText="#string/sizeFloatingLabel"
app:ms_highlightColor="#color/fuzionRed"
app:ms_hintColor="#color/fuzionRed"
app:ms_hint="Size"
app:ms_multiline="false"
app:ms_thickness="1dp" />
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/homeDetailsActivityNicotineSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
app:ms_arrowColor="#color/fuzionRed"
app:ms_arrowSize="16dp"
app:ms_baseColor="#color/fuzionRed"
app:ms_enableFloatingLabel="true"
app:ms_floatingLabelColor="#color/fuzionRed"
app:ms_floatingLabelText="#string/nicotineFloatingLabel"
app:ms_highlightColor="#color/fuzionRed"
app:ms_hintColor="#color/fuzionRed"
app:ms_multiline="false"
app:ms_hint="Nicotine"
app:ms_thickness="1dp" />
</LinearLayout>
<Button
android:id="#+id/homeDetailsActivityButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#color/fuzionRed"
android:text="Add To Cart"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>
change
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:scaleType="fitCenter" />
to
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:adjustViewBounds="true"
android:scaleType="fitStart" />

Categories

Resources