ViewPager under of BottomNavigation - java

I have list in viewpager and i have audio player on bottom. But my viewpager doesn't end the starting of audio player. I can't see my last 2 - 3 items in viewpager. And i don't wanna use MarginBottom.
some screenshots
my activity.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/coordinatorLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- AppBar Layout -->
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<!-- Tab Layout for creating tabs -->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<!-- Helps handing the Fragments for each Tab -->
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.BottomNavigationView
android:layout_width="fill_parent"
android:layout_height="90dp"
android:layout_marginTop="5dp"
android:layout_below="#+id/viewPager"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_gravity="bottom"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<android.support.design.widget.NavigationView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:paddingLeft="10dp"
android:layout_gravity="center"
android:paddingRight="10dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/btnBackward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginBottom="4dp"
android:src="#android:drawable/ic_media_rew" />
<ImageButton
android:id="#+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnBackward"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnBackward"
android:src="#android:drawable/ic_media_play" />
<ImageButton
android:id="#+id/btnPause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPlay"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnPlay"
android:src="#android:drawable/ic_media_pause" />
<ImageButton
android:id="#+id/btnForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPause"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnPause"
android:contentDescription="#+id/imageButton3"
android:src="#android:drawable/ic_media_ff" />
<TextView
android:id="#+id/txtStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/sBar"
android:text="0 min, 0 sec" />
<SeekBar
android:id="#+id/sBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/btnBackward"
android:layout_toLeftOf="#+id/txtSongTime"
android:layout_toRightOf="#+id/txtStartTime" />
<TextView
android:id="#+id/txtSongTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/sBar"
android:layout_toRightOf="#+id/btnForward"
android:text="0 min, 0 sec " />
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.design.widget.BottomNavigationView>
</android.support.design.widget.CoordinatorLayout>
I tried a couple solution but none of them worked. Only solution i can find is using marginbottom, but i think that would be bad choices.
Any help would be great. Thanks.

You can solve this by wrapping the ViewPager and the BottomNavigationView within a ConstraintLayout and add a constraint so that the bottom part of the ViewPager should be at the top part of the BottomNavigationView using: app:layout_constraintBottom_toTopOf attribute at the ViewPager
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
...
app:layout_constraintBottom_toTopOf="#id/bottom_nav_view"
And then make the height of the ViewPager match the constraints instead of the fill_parent or match_parent
To apply this change your layout to:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/coordinatorLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- AppBar Layout -->
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<!-- Tab Layout for creating tabs -->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<!-- Helps handing the Fragments for each Tab -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="#id/bottom_nav_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_nav_view"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="5dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintBottom_toBottomOf="parent"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<android.support.design.widget.NavigationView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageButton
android:id="#+id/btnBackward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginBottom="4dp"
android:src="#android:drawable/ic_media_rew" />
<ImageButton
android:id="#+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnBackward"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnBackward"
android:src="#android:drawable/ic_media_play" />
<ImageButton
android:id="#+id/btnPause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPlay"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnPlay"
android:src="#android:drawable/ic_media_pause" />
<ImageButton
android:id="#+id/btnForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPause"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/btnPause"
android:contentDescription="#+id/imageButton3"
android:src="#android:drawable/ic_media_ff" />
<TextView
android:id="#+id/txtStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/sBar"
android:text="0 min, 0 sec" />
<SeekBar
android:id="#+id/sBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/btnBackward"
android:layout_toLeftOf="#+id/txtSongTime"
android:layout_toRightOf="#+id/txtStartTime" />
<TextView
android:id="#+id/txtSongTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/sBar"
android:layout_toRightOf="#+id/btnForward"
android:text="0 min, 0 sec " />
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.design.widget.BottomNavigationView>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
Edit:
It's kind of worked. Bottom is fixed bot now i can't see Top, first 2 3 item under appBar. i tried couple of codes something like that app:layout_constraintBottom_toBottomOf="#id/appBarLayout" but doesn't worked.
Solution:
app:layout_constraintTop_toBottomOf="#+id/appBarLayout" and to gradle 'com.android.support.constraint:constraint-layout:1.0.2' now it's working.

Related

Android java - card slider match width to parent

I would like to create a horizontally scrolling photo gallery. I'm using https://github.com/IslamKhSh/CardSlider.
I would like the photo to be displayed across the entire width of the screen and the height of the photo to scale.
Unfortunately, currently the image is not displayed on the entire width of the screen, there are small margins (green area) screenshot.
I tried setting the margin and padding to 0 but it didn't help. What can I do to remove these margins?
Gallery item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="0dp"
>
<ImageView
android:id="#+id/image_poster"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#color/colorContrastYellow"
/>
<TextView
android:id="#+id/image_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp" />
</LinearLayout>
Activity with gallery
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/activity_details_social_bar"
android:background="#color/colorLightGrayBackground"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#color/colorLightGrayBackgroundTransparent"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="#color/colorRed">
<com.github.islamkhsh.CardSliderViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/greenCard"
app:cardSlider_indicator="#id/indicator"
app:cardSlider_otherPagesWidth="0dp"
app:cardSlider_pageMargin="0dp"
android:layout_margin="0dp"
android:padding="0dp"
app:cardSlider_smallScaleFactor="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.islamkhsh.CardSliderIndicator
android:id="#+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/viewPager" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_transparent" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/v_line"
android:orientation="vertical"
android:showDividers="middle">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_padding"
android:paddingTop="#dimen/dp10"
android:paddingRight="#dimen/activity_padding"
android:paddingBottom="#dimen/dp10">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/activity_details_news_TV_category"
style="#style/AppTheme.DetailsSectionTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/dp12" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/activity_details_news_CIV_author_photo_static"
android:layout_width="#dimen/author_image_size"
android:layout_height="#dimen/author_image_size"
android:layout_alignTop="#+id/activity_details_news_TV_author"
android:layout_alignBottom="#+id/activity_details_news_TV_publ_date"
android:layout_alignParentLeft="true"
android:layout_marginRight="#dimen/dp8" />
<ImageView
android:id="#+id/activity_details_news_IMG_line"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="#+id/activity_details_news_TV_author"
android:layout_alignBottom="#+id/activity_details_news_TV_publ_date"
android:layout_marginRight="#dimen/dp8"
android:layout_toRightOf="#+id/activity_details_news_CIV_author_photo_static"
android:src="#drawable/h_line" />
<TextView
android:id="#+id/activity_details_news_TV_author"
style="#style/AppTheme.DetailsAuthorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/activity_details_news_TV_category"
android:layout_toRightOf="#+id/activity_details_news_IMG_line" />
<TextView
android:id="#+id/activity_details_news_TV_publ_date"
style="#style/AppTheme.DetailsAuthorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/activity_details_news_TV_author"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/activity_details_news_IMG_line" />
</RelativeLayout>
<TextView
android:id="#+id/activity_details_news_TV_title"
style="#style/AppTheme.DetailsTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp12" />
<TextView
android:id="#+id/activity_details_news_TV_headline"
style="#style/AppTheme.DetailsAbstrTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp12" />
<TextView
android:id="#+id/activity_details_news_TV_descr"
style="#style/AppTheme.DetailsContentTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp8" />
</LinearLayout>
<LinearLayout
android:id="#+id/activity_details_news_LL_editorial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/linear_vertical_contact_spacing"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_padding"
android:paddingTop="#dimen/dp10"
android:paddingRight="#dimen/activity_padding"
android:paddingBottom="#dimen/dp10"
android:showDividers="middle">
<TextView
android:id="#+id/tvEditorial"
style="#style/AppTheme.DetailsSectionTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/editorial" />
<TextView
android:id="#+id/activity_details_news_TV_phone"
style="#style/AppTheme.DetailsContactTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/vertical_phone" />
<TextView
android:id="#+id/activity_details_news_TV_email"
style="#style/AppTheme.DetailsContactTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/vertical_message" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/activity_details_news_CIV_author_photo"
android:layout_width="#dimen/author_image_size"
android:layout_height="#dimen/author_image_size"
android:layout_marginLeft="#dimen/activity_padding"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|left"
app:layout_behavior="com.yarmobile.gminy.utils.behaviors.NewsDetailsAuthorImageBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
android:id="#+id/activity_details_social_bar"
layout="#layout/activity_details_social_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<include
android:id="#+id/progress_wheel"
layout="#layout/blocking_progress_wheel"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
I tried setting the margin and padding to 0 but it didn't help.
you can use RecyclerView if you have list of Images to scroll Horizontal Image

Inflating another layout with drawer layout

Greetings my fellow programmers,
I've got an easy one i'd guess but i still don't know why it causes such behaviour.
So the scene is this: i've got appliaction which plays music via service and the mini player at the bottom which i've added in a way that i inflated main layout.
If i do not inflate layout with the mini player i can use method's (menu items) inside drawer normally (it takes me to wanted destination and triggers sliding operations flawlessly) once i start playing music i infalte the layout so i show the player and i can do this with drawer :
I can open it from sliding and from hamburger button
I can open it from sliding and from hamburger button
I CAN'T CLOSE it by right-left slide
METHODS DO NOT work inside drawer
Any ideas why inflating messes it up?
P.S
On the main layout i use Coordinator Layout at parent view so i can use floating buttons
***** EDIT: HERE ARE SCREENS ******
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/cili_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.android.listenyo_41.MainActivity"
android:background="#color/white">
<!-- Loading indicator is only shown before the first load -->
<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"
tools:context="com.example.android.listenyo_41.MainActivity"
android:id="#+id/cili_test2"
android:background="#color/black"
>
<!-- Loading indicator is only shown before the first load -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/nesto_glupo"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/black">
<ImageButton
/>
<android.support.v7.widget.Toolbar
/>
<com.miguelcatalan.materialsearchview.MaterialSearchView
/>
</RelativeLayout>
<ListView
/>
<RelativeLayout
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:background="#color/black"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:id="#+id/test_fade"
>
<Button
/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
/>
</android.support.v4.widget.SwipeRefreshLayout>
<!-- Empty view is only visible when the list has no items. -->
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<TextView
/>
<ProgressBar
/>
</RelativeLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/drawer_view"
app:headerLayout="#layout/nav_header"
app:itemIconTint="#color/white"
android:background="#color/black"
app:itemTextColor="#color/white"
/>
</android.support.v4.widget.DrawerLayout>
<ProgressBar
android:id="#+id/picasso_progress"
style="#android:style/Widget.Holo.Light.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#75d9534f"
android:id="#+id/crvena_traka"
>
<RelativeLayout
android:id="#+id/songName_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="135dp"
android:layout_marginTop="5dp"
android:paddingEnd="6dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingStart="6dp"
android:progressDrawable="#drawable/progress_drawable"
android:thumbTint="#color/black"
android:visibility="gone"
/>
<TextView
android:id="#+id/songDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/seekBar"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="140dp"
android:layout_marginTop="2dp"
android:text="00:00:00"
android:textColor="#color/white"
android:textStyle="bold"
android:visibility="gone"
/>
<com.example.android.listenyo_41.ScrollTextView
android:id="#+id/songName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/seekBar"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="2dp"
android:layout_toLeftOf="#id/songDuration"
android:textColor="#color/white"
android:textSize="14sp"
android:textStyle="bold"
android:visibility="gone"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/btn_lay_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="Buffering"
android:textAlignment="center"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="gone"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/player_controler"
android:layout_weight="2">
<ProgressBar
android:id="#+id/loading_indicator2"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:indeterminateDrawable="#drawable/my_border4"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/player_controler2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#color/black"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginTop="20dp"
android:orientation="vertical"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
android:choiceMode="singleChoice"
android:divider="#null"
android:dividerHeight="5dp"
android:orientation="horizontal"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:visibility="gone">
<TextView
android:id="#+id/empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:gravity="center"
android:textAppearance="?android:textAppearanceMedium"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/drawer_view"
app:headerLayout="#layout/nav_header"
app:itemIconTint="#color/white"
android:background="#color/black"
app:itemTextColor="#color/white"
/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
And the mini player
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:id="#+id/play_test"
android:visibility="visible"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#color/myColor"
android:elevation="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:id="#+id/play_lay"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="#drawable/bl_tran_grad"
>
<RelativeLayout
android:id="#+id/icon_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:onClick="player"
>
<ProgressBar
style="#android:style/Widget.Holo.Light.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:visibility="gone"
android:id="#+id/picasso_progress2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="center"
android:id="#+id/error2"
android:text="Error loading picture"
android:textColor="#color/black"
android:textSize="13sp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/player_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
>
</ImageView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_margin="5dp"
android:onClick="player"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:id="#+id/songName2"
android:textSize="14sp"
android:layout_centerVertical="true"
android:textColor="#color/white"
android:textStyle="bold"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="player_2_pause"
>
<ImageView
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_centerInParent="true"
android:src="#drawable/ic_launcher"
android:onClick="player_2_resume"
android:visibility="invisible"
android:id="#+id/player_2_resume"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buffering"
android:textColor="#color/white"
android:layout_centerInParent="true"
android:textSize="14sp"
android:visibility="visible"
android:id="#+id/buffering"
/>
<ImageView
android:layout_width="50dp"
android:layout_height="35dp"
android:src="#drawable/pause2"
android:onClick="player_2_pause"
android:visibility="invisible"
android:id="#+id/player_2_pause"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<SeekBar
android:padding="0dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:id="#+id/seekBar_player2"
android:layout_width="match_parent"
android:layout_height="4.0dp"
android:layout_above="#id/play_lay"
android:background="#80000000"
android:maxHeight="5dp"
android:minHeight="4dp"
android:progressDrawable="#drawable/progress_drawable"
android:max="10"
android:thumb="#color/white"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp" />
</RelativeLayout>
When player active[1]
without player drawer[2]
both[3]
[1]: https://i.stack.imgur.com/gD0BY.jpg
[2]: https://i.stack.imgur.com/0zcYP.jpg
[3]: https://i.stack.imgur.com/qFY6q.jpg

Adjust pan issue in android keyboard

So basically i want to push the bottom button to top of the keyboard and push the other content up after opening the keyboard.
The problem is that if i use adjust pan the button overlap with the edit text and if i use the adjust resize button won't come up.
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical"
tools:context="com.lifeincontrol.activities.home.AddCompanionActivity"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:background="?attr/colorPrimary"
android:titleTextColor="#android:color/white"
app:popupTheme="#style/AppTheme.PopupOverlay"
>
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="#+id/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/companion_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:src="#drawable/ic_add_companion_illustration"
/>
<LinearLayout
android:id="#+id/number_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/companion_image"
android:layout_marginLeft="15dp"
android:layout_marginTop="62dp"
android:orientation="horizontal"
>
<LinearLayout
android:id="#+id/country_code_layout_before"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="7dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/text_country_code_before"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="12dp"
android:drawableRight="#drawable/arrow_drop_down"
android:src="#drawable/flag_in"
/>
<ImageView
android:id="#+id/drop_down_before"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="12dp"
android:paddingTop="12dp"
android:src="#drawable/down_arrow_logging"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:background="#5E000000"
/>
</LinearLayout>
<EditText
android:id="#+id/number_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:hint="Phone Number"
android:inputType="number"
android:maxLines="1"
android:textColorHint="#aaa"
/>
<ImageView
android:id="#+id/phone_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="11dp"
android:src="#drawable/circle"
android:visibility="gone"
/>
</LinearLayout>
<EditText
android:id="#+id/name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/number_field"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="30dp"
android:hint="Name"
android:imeActionLabel="Done"
android:imeOptions="actionDone"
android:maxLines="1"
android:singleLine="true"
android:textColorHint="#aaa"
/>
<View
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_below="#+id/name_edit_text"
/>
<Button
android:id="#+id/button_send"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:background="#color/companion_button_send"
android:text="Send"
android:textColor="#color/white"
android:textSize="14sp"
/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
first image before keyboard open
second image here i want to show the green button on top of keyboard
Add the below line to your activity java file
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
And then add a ScrollView to the layout. Remember ScrollView can hold only 1 child view.
<ScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<--------Your content---------->
</RelativeLayout>
</ScrollView>
1.change adjustpan to adjustResize in your menifest file like below
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustResize|stateHidden"/>
put your xml code inside scrollView
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<--------Your content---------->
</RelativeLayout>
</ScrollView>

scrollview not scrolling android

The ScrollView item is not doing what it should: I canĀ“t scroll.
The code below is a part from a fragment, with splitted screen (thats why I use weight=1). The content of the RelativeLayout is added via code dynamically. The content appears correctly, it is more that could fit onto the screen, so it should be possible to scroll.
I tried out several things:
changing RelativesLayout-height to wrap-content
adding fillViewport="true" to the ScrollView
scrollview not as root element
THE LAYOUT FILE OF THE FRAGMENT
<LinearLayout
android:id="#+id/schichten"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="tuerk.fabian.polarfuchs.AllgemeineInfosFragment">
<ScrollView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fillViewport="true" >
<RelativeLayout android:id="#+id/schichten_upper_half"
android:isScrollContainer="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"/>
</ScrollView>
THE LAYOUT FILE OF THE CONTENT THAT IS DYNAMICALLY ADDED TO THE FRAGMENT (INTO #+id/schichten_upper_half)
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/schichten_ansicht_haerte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FA"
android:textSize="20sp"
android:paddingRight="10sp"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/schichten_ansicht_von_height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 cm"
android:layout_toRightOf="#+id/schichten_ansicht_haerte"/>
<TextView
android:id="#+id/schichten_ansicht_bis_height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 cm"
android:layout_below="#id/schichten_ansicht_von_height"
android:layout_toRightOf="#+id/schichten_ansicht_haerte"/>
<TextView
android:id="#+id/schichten_ansicht_naesse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:textSize="20sp"
android:paddingLeft="10sp"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/schichten_ansicht_bis_height"/>
<ImageView
android:id="#+id/schichten_ansicht_1st_grain_form"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/df"
android:paddingLeft="10sp"
android:layout_toRightOf="#id/schichten_ansicht_naesse"/>
<ImageView
android:id="#+id/schichten_ansicht_2nd_grain_form"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/df"
android:layout_toRightOf="#id/schichten_ansicht_1st_grain_form"/>
<TextView
android:id="#+id/schichten_ansicht_durchmesser_von"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0.1 "
android:layout_centerVertical="true"
android:paddingLeft="10sp"
android:layout_toRightOf="#+id/schichten_ansicht_2nd_grain_form"/>
<TextView
android:id="#+id/schichten_ansicht_durchmesser_bis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="- 0.3 mm"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/schichten_ansicht_durchmesser_von"/>
</RelativeLayout>
THE LAYOUT FILE OF THE ACITIVITY
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" />

android view layout. make view fill space between views

I am trying to create a layout with basically a head, body, and footer. The ViewPager I am using is filling the space behind the footer content though. How can I make it not do this, and cutoff at the start of the footer content?
<?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:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.janedoe.anothertabexample.MainActivity"
tools:showIn="#layout/activity_main">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="#id/tabLayout"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp">
<TextView
android:id="#+id/time"
android:layout_width="100dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center"
android:text="00:00:00"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/mileage"
android:layout_width="100dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="0.0 mi"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#id/time"
android:text="Start" />
<Button
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#id/mileage"
android:text="Stop" />
</RelativeLayout>
</RelativeLayout>
I don't want the color(which is just the content) to run past the Buttons and TextViews on the bottom. I've tried the layout_gravity method as well as setting the viewpager to layout_above and layout_blow but neither appear to work. How can I achieve this?
You view pager will consume all space available.
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="#id/tabLayout"/>
I would try switching to a LinearLayout and use the "android:layout_weight" property to force the ViewPager to only use available space.
your RelativeLayout should have android:layout_alignParentBottom="true".
<RelativeLayout android:id="#+id/relativeFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="5dp">
Remove android:layout_alignParentBottom="true" from all its child.
and your viewpager should look like below
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/relativeFooter"
android:layout_below="#id/tabLayout"/>
Finally your whole layout should be like below :
<?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:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/relativeFooter"
android:layout_below="#id/tabLayout"/>
<RelativeLayout android:id="#+id/relativeFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="5dp">
<TextView
android:id="#+id/time"
android:layout_width="100dp"
android:layout_height="55dp"
android:layout_alignParentLeft="true"
android:gravity="center"
android:text="00:00:00"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/mileage"
android:layout_width="100dp"
android:layout_height="55dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="0.0 mi"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#id/time"
android:text="Start" />
<Button
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#id/mileage"
android:text="Stop" />
</RelativeLayout>

Categories