How to handle different font sizes of text? - android

This is my issue.
All text size in my app screen looks fine when my user chooses font size to be small from android
settings-->display -->Text size --> small
same app screen looks messy when my user chooses font size to be large from android
settings-->display -->Text size --> Large
How to make my app screens look better in all font sizes
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/voicemailcontactpic"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:src="#drawable/unknown_contact"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="#+id/voicemailcontactname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/transparent"
android:ellipsize="end"
android:text="Unknown"
android:maxLines="1"
android:textSize="14sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:layout_toEndOf="#id/voicemailcontactpic"
android:layout_toRightOf="#id/voicemailcontactpic"
android:layout_alignTop="#+id/voicemailcontactpic"/>
<TextView
android:id="#+id/voicemailcontactnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/voicemailcontactname"
android:layout_alignStart="#+id/voicemailcontactname"
android:layout_below="#+id/voicemailcontactname"
android:layout_alignBottom="#+id/voicemailcontactpic"
android:background="#color/transparent"
android:ellipsize="end"
android:maxLines="1"
android:text="1234"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:textSize="12sp" />
<TextView
android:id="#+id/voicemaildownloadsize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/voicemaildownload"
android:layout_toLeftOf="#id/voicemaildownload"
android:layout_alignTop="#id/voicemailcontactpic"
android:text="122kb"
android:textSize="12sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
android:textAlignment="viewEnd"
tools:ignore="RtlCompat"
/>
<TextView
android:id="#+id/voicemailrecievedtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_toStartOf="#id/voicemaildownload"
android:layout_toLeftOf="#id/voicemaildownload"
android:layout_below="#+id/voicemailcontactname"
android:layout_alignBottom="#id/voicemailcontactpic"
android:text="12:01 PM"
android:textAlignment="viewEnd"
android:textSize="12sp"
android:fontFamily="calibri"
android:textColor="#color/grey_font"
tools:ignore="RtlCompat"
/>
<com.nexge.nexgetalkclass5.app.voicemail.CircularProgressBar
android:id="#+id/voice_mail_file_download_Progress"
style="#style/Widget.ProgressBar.Holo.CircularProgressBar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="16dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="16dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
/>
<ImageView
android:id="#+id/voicemaildownload"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignBottom="#+id/voicemailcontactpic"
android:layout_alignTop="#id/voicemailcontactpic"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/voicemail_download"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/voicemail_player_layout"
android:paddingBottom="10dp"
>
<ImageView
android:id="#+id/voicemail_player_play_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:src="#drawable/media_player_play"
/>
<ImageView
android:id="#+id/voicemail_player_pause_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:src="#drawable/media_player_pause"
android:visibility="invisible"
/>
<SeekBar
android:id="#+id/voicemail_player_seekbar"
android:layout_width="match_parent"
android:layout_toEndOf="#+id/voicemail_player_play_btn"
android:layout_toRightOf="#+id/voicemail_player_play_btn"
android:layout_alignTop="#+id/voicemail_player_play_btn"
android:progressTint="#color/colorPrimary"
android:thumb="#drawable/seekbar_thumb"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"/>
<TextView
android:id="#+id/voicemail_file_start_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/voicemail_player_seekbar"
android:layout_alignStart="#+id/voicemail_player_seekbar"
android:layout_alignLeft="#+id/voicemail_player_seekbar"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:fontFamily="calibri"
/>
<TextView
android:id="#+id/voicemail_file_end_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="calibri"
android:layout_alignEnd="#+id/voicemail_player_seekbar"
android:layout_alignRight="#+id/voicemail_player_seekbar"
android:layout_below="#+id/voicemail_player_seekbar"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
/>
</RelativeLayout>
</LinearLayout>

Don't use textsize, Use textAppearance for fontSize

Related

Appearance of the text color is white in the real device though it has been mentioned black ( working fine in the emulator)

So, I was trying to create a customized wedding card in Android Studio. The code is given below. I noticed difference in textColor while building it in the emulator and real device. Though the color of this attribute has been defined as black but in the real device it appears as white. Screenshots of the real device and emulator appearance have been mentioned in the link below:
Appearance in the Real Device
Appearance in the Emulator
Android Studio Version: 4.1.1
Any suggestions about how this issue can be solved in terms of real device?
Thanks in advance.
<?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/wedding_Card"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/wedding_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="#drawable/wedding_card"
android:contentDescription="TODO" />
<ImageView
android:id="#+id/petals"
android:layout_width="325dp"
android:layout_height="716dp"
android:layout_centerInParent="true"
android:contentDescription="TODO"
app:srcCompat="#drawable/pink" />
<ImageView
android:id="#+id/flower_top"
android:layout_width="186dp"
android:layout_height="88dp"
android:layout_above="#id/save_date"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-30dp"
app:srcCompat="#drawable/floral_pattern"
android:contentDescription="TODO" />
<TextView
android:id="#+id/save_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/date"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/save_the_day"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold"
android:visibility="visible"
tools:visibility="visible" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/flower_bou"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/_25_12_2020"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
tools:visibility="visible" />
<TextView
android:layout_width="52dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginRight="6dp"
android:layout_marginBottom="7dp"
android:layout_toLeftOf="#id/flower_bou"
android:fontFamily="cursive"
android:text="#string/emma"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginEnd="6dp"
android:layout_toStartOf="#id/flower_bou" />
<ImageView
android:id="#+id/flower_bou"
android:layout_width="81dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
app:srcCompat="#drawable/flower_bouquet"
android:contentDescription="TODO" />
<TextView
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginStart="6dp"
android:layout_marginLeft="-21dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:layout_marginBottom="3dp"
android:layout_toRightOf="#id/bride_groom"
android:fontFamily="cursive"
android:text="#string/dexter"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_toEndOf="#id/bride_groom" />
<ImageView
android:id="#+id/bride_groom"
android:layout_width="133dp"
android:layout_height="111dp"
android:layout_centerInParent="true"
app:srcCompat="#drawable/bride_groom"
android:contentDescription="TODO" />
<TextView
android:id="#+id/We_getting_married"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/bride_groom"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/we_are_getting_married"
android:textColor="#color/black"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/time"
android:layout_centerHorizontal="true"
android:layout_below="#id/We_getting_married"
android:text="#string/at_five_o_clock_in_the_evening"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cityLove"
android:layout_centerHorizontal="true"
android:layout_below="#id/time"
android:text="#string/city_of_love"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/avenue"
android:layout_centerHorizontal="true"
android:layout_below="#id/cityLove"
android:text="#string/flower_avenue"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/church"
android:layout_centerHorizontal="true"
android:layout_below="#id/avenue"
android:text="#string/st_rose_church"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:id="#+id/dinner_dancing_to_follow"
android:layout_width="wrap_content"
android:layout_height="41dp"
android:layout_below="#id/church"
android:layout_centerHorizontal="true"
android:layout_marginTop="-10dp"
android:fontFamily="cursive"
android:text="#string/dinner_and_dancing_to_follow"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>

RelativeLayout breaks on pre-Marshmallow devices

I am facing a problem while populating a list view. Following is my layout for a list item.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<CheckBox
android:id="#+id/item_pay_periods_check_box"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:button="#drawable/btn_check"
android:layout_below="#+id/item_pay_periods_date"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:visibility="visible"/>
<TextView
android:id="#+id/item_pay_periods_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mon Sep 12"
android:textSize="13sp"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_alignParentTop="true"/>
<TextView
android:id="#+id/item_pay_periods_time_in"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="12:00 am"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_below="#+id/item_pay_periods_date"
android:layout_marginTop="5dp"
android:textSize="13sp"/>
<TextView
android:id="#+id/item_pay_periods_time_out"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="#+id/item_pay_periods_time_in"
android:text="12:00 am"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_marginTop="5dp"/>
<TextView
android:id="#+id/item_pay_periods_service_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Attendant care service service service"
android:textSize="13sp"
android:textStyle="bold"
android:layout_alignBaseline="#+id/item_pay_periods_time_in"
android:layout_toRightOf="#+id/item_pay_periods_time_in"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:maxLines="1"
android:ellipsize="end"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration" />
<TextView
android:id="#+id/item_pay_periods_activities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Housework, shopping, shopping, shopping"
android:layout_below="#+id/item_pay_periods_service_name"
android:layout_toRightOf="#+id/item_pay_periods_time_out"
android:layout_marginLeft="5dp"
android:layout_alignBaseline="#+id/item_pay_periods_time_out"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration"
android:visibility="visible"/>
<LinearLayout
android:id="#+id/itemPayPeriodsNotesLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/item_pay_periods_activities"
android:layout_toRightOf="#+id/item_pay_periods_time_out"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration"
android:layout_marginTop="5dp">
<ImageView
android:id="#+id/item_pay_periods_img_tag"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_tag"
android:layout_gravity="center_vertical"/>
<TextView
android:id="#+id/item_pay_periods_notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="made trip to CVC"
android:textSize="13sp"
android:layout_marginLeft="5dp"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<TextView
android:id="#+id/item_pay_periods_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5h 00m"
android:textSize="13sp"
android:layout_alignBaseline="#+id/item_pay_periods_time_in"
android:layout_alignBottom="#+id/item_pay_periods_time_in"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="visible"/>
<ImageView
android:id="#+id/item_pay_periods_img_submit_check_icon"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_check"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:tint="#color/blue"
android:visibility="visible"/>
<TextView
android:id="#+id/item_pay_periods_entry_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/item_pay_periods_img_submit_check_icon"
android:text="Rejected"
android:textSize="12sp"
android:textColor="#color/red"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
This is how it looks on Marshmallow and Nougat devices
Not overlapping views
And this is how it looks on Lollipop and pre lollipop devices
Overlapping views
Can anyone tell me why this is happening? Or anybody have faced such issue? Thanks in advance.

Android:placing layouts over each other

i am having an issue in over-lapping layouts,i am trying to implement an login form with in the entire page , and a button at the bottom , when the user press this button a registration form slides from bottom to up , my problems are:the first the registration form push the entire screen (i want it to overflow), the second: that i have 2 buttons with a shape background that appears on the top of registration form and the login inputs remains active
my xml code
<?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/content_login_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
tools:context="com.example.a3wd.mytest10.LoginPage"
tools:showIn="#layout/activity_login_page">
<ImageView
android:id="#+id/login2Logo"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:contentDescription="#string/fixawy_logoPic"
android:src="#drawable/logo2" />
<LinearLayout
android:id="#+id/loginInputs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login2Logo"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:layout_width="140dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:text="#string/loginText"
android:textColor="#color/loginText"
android:textSize="24sp"
android:textStyle="bold" />
<EditText
android:id="#+id/userEmail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/myspinner"
android:hint="#string/nameHint"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="#+id/userPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/myspinner"
android:hint="#string/passwordHint"
android:inputType="textPassword"
android:padding="10dp"
android:textAlignment="textEnd" />
</LinearLayout>
<Button
android:id="#+id/loginBtn"
android:layout_width="96dp"
android:layout_height="56dp"
android:layout_below="#id/loginInputs"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/shape_round_corner"
android:text="#string/enterBtnTxt"
/>
<TextView
android:id="#+id/passwordText"
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_alignBaseline="#id/loginBtn"
android:layout_alignParentRight="true"
android:layout_below="#id/loginInputs"
android:layout_marginRight="50dp"
android:text="#string/forgetPassword"
android:textColor="#color/loginText"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/facebookTxt"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="#id/loginBtn"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/facebookTxt"
android:textSize="18sp" />
<Button
android:id="#+id/facebookBtn"
android:layout_width="88dp"
android:layout_height="32dp"
android:layout_below="#id/facebookTxt"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/facebookbtn"
android:text="#string/facebook_btn"
android:textColor="#ffffff" />
<TextView
android:id="#+id/newUserTxt"
android:layout_width="140dp"
android:layout_height="20dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="#string/newUserTxt"
android:textSize="18sp"
android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_above="#+id/registrationBtn"
/>
<Button
android:id="#id/registrationBtn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/register_btn_shape"
android:gravity="right"
android:onClick="registerFragment"
android:layout_alignParentBottom="true"
android:paddingEnd="40dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/registerForm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/newUserTxt"
android:background="#drawable/register_back"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="right"
android:paddingEnd="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"
/>
</LinearLayout>
</RelativeLayout>
and the java code for animation
Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.bottom_up);
registrationForm.startAnimation(bottomUp);
registrationForm.setVisibility(View.VISIBLE);
this is the original view
and this is an image of the problem

Align Parent Bottom With Below RelativeLayout Android

Good day.I have an set of buttons which should be aligned to the bottom always,but they all also should be below an text,and it goes like this,if text is large,it is going just to push the buttons inside the scrollview,otherwise the buttons should be aligned to the parent bottom.Issue is that i add both of the tags to the linear layout wrapper of the buttons,but as soon as i set visibility of text to gone,the view just pops up and not aligning to parent bottom,here is the actual code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/single_product_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/single_product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:src="#drawable/img_placeholder" />
<RelativeLayout
android:id="#+id/basket_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_divider"
android:layout_alignEnd="#+id/single_product_divider"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/basket_success_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginLeft="26dp"
android:src="#drawable/success_icon" />
<TextView
android:id="#+id/basket_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/basket_success_icon"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/basket_success_icon"
android:text="#string/product_added_to_basket_text"
android:textColor="#ffffff"
android:textSize="16sp" />
</RelativeLayout>
<View
android:id="#+id/single_product_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/single_product_image"
android:layout_margin="25dp"
android:background="#D1D3D4">
</View>
<TextView
android:id="#+id/single_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_divider"
android:text="#string/loading_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_weight_and_servings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_name"
android:layout_marginTop="5dp"
android:text="#string/weight_and_servings_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_weight_and_servings"
android:layout_alignStart="#+id/single_product_weight_and_servings"
android:layout_below="#+id/single_product_weight_and_servings"
android:layout_marginTop="15dp"
android:text="$12.09"
android:textColor="#009444"
android:textSize="17sp"
android:textStyle="bold" />
<RatingBar
android:id="#+id/single_product_rating"
style="#style/Base.Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_price"
android:layout_alignStart="#+id/single_product_price"
android:layout_below="#+id/single_product_price"
android:layout_marginTop="5dp"
android:numStars="5" />
<TextView
android:id="#+id/single_product_rating_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating"
android:text="10.0/10"
android:textColor="#231F20"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_review_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating_text"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating_text"
android:text="8 reviews"
android:textColor="#EC2027"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_stock_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/single_product_review_count"
android:layout_marginRight="10dp"
android:text="In stock"
android:textColor="#939598" />
<View
android:id="#+id/single_product_center_divider"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/single_product_rating"
android:layout_centerHorizontal="true"></View>
<Spinner
android:id="#+id/single_product_weight_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="10dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<Spinner
android:id="#+id/single_product_type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="2dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_type_spinner"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<RelativeLayout
android:id="#+id/single_product_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="#string/add_to_cart_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_add_to_cart_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_info_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_nutritional_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_nutritional_info_button"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_reviews_text"
android:textAllCaps="false"
android:textColor="#231F20" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Can anyone please give any suggestion?
Edit : The full code of the view,actual buttons are inside RelativeLayout at the bottom of xml files there are 4 of buttons.The wrapper is single_product_buttons_wrapper
Add android:gravity="bottom" to LinearLayout containing buttons. It will work have tested it.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:gravity="bottom"
android:orientation="vertical">
Try this:
<?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"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_info_button"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="123"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_nutritional_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="234"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_reviews_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="5555"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="99999"
android:textAllCaps="false"
android:textColor="#231F20" />
</LinearLayout>
</RelativeLayout>

App android design is damaged from api 21 but works in api 20 and backward

the position of the buttons is damaged, when I change to the api 21, they are stretched. But in api 20 and backward works good. I'm working on android studio 1.5.1
works good on api 20 see the image
Edit:
xml layout for MainActivity.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/background"
android:id="#+id/RootView"
tools:context=".MainActivity">
<RelativeLayout
android:id="#+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:minWidth="255dp"
android:gravity="center_horizontal"
android:text="#string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_height="1dip"
android:background="#555555"
android:layout_below="#+id/titleTextView" />
<ImageView
android:id="#+id/stationImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_below="#+id/trackTextView"
android:layout_above="#+id/statusTextView"
android:src="#drawable/station_default"
android:contentDescription="#null" />
<TextView
android:id="#+id/artistTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp"
android:layout_alignStart="#+id/stationImageView"
android:layout_alignLeft="#+id/stationImageView"
android:gravity="start"
android:text="#string/artist"
android:textSize="12sp" />
<TextView
android:id="#+id/trackTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="55dp"
android:layout_alignStart="#+id/stationImageView"
android:layout_alignLeft="#+id/stationImageView"
android:gravity="start"
android:text="#string/current_player_track"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14sp" />
<TextView
android:id="#+id/albumTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/artistTextView"
android:layout_alignBottom="#+id/artistTextView"
android:layout_alignRight="#+id/stationImageView"
android:layout_alignEnd="#+id/stationImageView"
android:gravity="start"
android:text="#string/album"
android:textSize="12sp" />
<TextView
android:id="#+id/timeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/trackTextView"
android:layout_alignBottom="#+id/trackTextView"
android:layout_alignRight="#+id/stationImageView"
android:layout_alignEnd="#+id/stationImageView"
android:gravity="start"
android:text=""
android:textSize="12sp" />
<TextView
android:id="#+id/statusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/volumebar"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:paddingBottom="5dp"
android:text="#string/status_noconnection" />
<Button
android:id="#+id/PauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/titleTextView"
android:layout_alignLeft="#+id/titleTextView"
android:layout_marginBottom="0dp"
android:background="#drawable/btn_pause"
android:onClick="onClickPauseButton"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/PlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/titleTextView"
android:layout_alignLeft="#+id/titleTextView"
android:layout_marginBottom="0dp"
android:background="#drawable/btn_play"
android:onClick="onClickPlayButton"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/StopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/titleTextView"
android:layout_alignEnd="#+id/titleTextView"
android:layout_marginBottom="0dp"
android:background="#drawable/btn_stop"
android:onClick="onClickStopButton"
android:layout_alignParentEnd="true" />
<Button
android:id="#+id/NextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/StopButton"
android:layout_toStartOf="#+id/StopButton"
android:layout_marginBottom="0dp"
android:background="#drawable/btn_next"
android:onClick="onClickNextButton"
android:layout_alignParentStart="false"
android:layout_alignParentEnd="false" />
<Button
android:id="#+id/PreviousButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/PlayButton"
android:layout_toEndOf="#+id/PlayButton"
android:layout_marginBottom="0dp"
android:background="#drawable/btn_previous"
android:onClick="onClickPreviousButton" />
<ImageView
android:id="#+id/vol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/volumebar"
android:layout_alignLeft="#+id/stationImageView"
android:layout_alignStart="#+id/stationImageView"
android:layout_alignTop="#+id/volumebar"
android:src="#drawable/icon_volume"
android:contentDescription="#null"/>
<SeekBar
android:id="#+id/volumebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/PlayButton"
android:layout_alignRight="#+id/stationImageView"
android:layout_alignEnd="#+id/stationImageView"
android:layout_toRightOf="#+id/vol"
android:layout_toEndOf="#+id/vol"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<com.google.android.gms.ads.AdView
android:id="#+id/adLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/admob_publisher_id" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Add the image in all drawable folders, like mdpi , xhdpi , xxhdpi , xxxhdpi etc. The newer version phone might have a higher resolution and needs a better image for it to work
My solution was to use the object ImageButton instead of Button in activity_main.xml
with this I could fix the problem.

Categories

Resources