I'd like to add some padding to my recycler view so the status bar doesn't cover the first item. The problem is when I apply top padding, a solid white shows on top preventing the full screen experience.
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/RecentVizzyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="48dp" />
<ProgressBar
android:id="#+id/progressbar"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateTint="#color/lightGreen"
android:indeterminateTintMode="src_atop" />
</android.support.design.widget.CoordinatorLayout>
and I'm setting no limits flag to my screen:
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Set android:clipToPadding="false" on your RecyclerView.
That will allow the paddingTop (and bottom, if you want), to be part of the scrollable part.
A better description is found here:
Android what does the clipToPadding Attribute do?
Related
I have one problem with the BottomNavigationBar. Inexplicable margins from the edges of the screen appear like on the screen.
Here is my XML cod:
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#FBCEB5">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/mainNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="#color/colorPrimary"
app:menu="#menu/main_bottom_bar"
app:itemIconTint="#android:color/white"
app:itemTextColor="#android:color/white"/>
</RelativeLayout>
How i can put on all parent width ? Please help)
According to this post, BottomNavigationView is not full width, the bottom navigation bar is not supposed to fill the entire width. Instead, you could set the background color of the view to be the same color as the items background:
<android.support.design.widget.BottomNavigationView
android:background="#color/bottom_view_color"
app:itemBackground="#color/bottom_view_color"
// .... />
I have a RecyclerView that includes my custom view.
My custom view not get all the width even so I configure it as match_parent.
what i want is that the horizontal scroll view will take all screen, and also the card will take screen width (so the yelow part will stay outside at beginning)
I've tried to use LayoutInflater.from(getContext()).inflate(R.layout.view_home_screen_card, (ViewGroup) this, false), but didn't work
Also I've tried to set width programmatically, but I'm seeing the wrong size for few milliseconds before it's change and its look ugly.
The weird thing is that when i'm taking out the horizontal scroll view, the view take all place.
attached the layout
<?xml version="1.0" encoding="utf-8"?> <merge
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="wrap_content">
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/horizontal_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:id="#+id/view_home_card_and_button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="100dp"
android:layout_height="150dp"
android:background="#color/amber_200" />
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/half_unit"
app:cardCornerRadius="#dimen/8dp">
</android.support.v7.widget.CardView>
</LinearLayout>
</HorizontalScrollView>
</merge>
any more ideas?
Is your recyclerview have match_parent width? If no then make it.
For some reason a small shadow appears on top of my floating action button as seen here but only on the debugging device but not in the Android Studio preview.
The button is nested in a relative layout to position it in the bottom of the screen like this:
<?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">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="16dp"
android:src="#drawable/baseline_play_circle_outline_white_36" />
</RelativeLayout>
Update:
This is what it looks like when clicked.
The problem is also caused by adding an alpha value to the FAB like here
but in my case, as the shadow color is almost the same as the original, adding 0.9 alpha makes it way less obvious.
try adding following attributes to fab :
android:clipChildren="false"
android:clipToPadding="false"
I want to set the logo of my app to the bottom left hand side of the screen and be in the background. the reason i want to do this is to allow the users to modify the background colors which would not be possible if i simply set the entire activity or layout background to an image to give same impression.
Another way of asking this is how do i set an image to bottom left hand corner and below other controls?
i don't know if i understand correct. but what you ask is pretty simple.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="bottom|left"
android:layout_margin="10dp"
android:src="#ffff00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<!-- Put your views here -->
</LinearLayout>
</FrameLayout>
you can change the frame layout's background as you wish and keep logo on bottom left corner.
Also you can set your LinearLayout (which you can use any layout. it is up to you) background to transparent so you will see background. and any extra view inside the linear layout (your view container) will be on top always.
<?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"
android:background="#drawable/your_desired_full_background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher_logo"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
I have the following layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/top_banner"
android:name="com.apps4care.mycarerecord.fragments.patientBannerFragment"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentTop="true"
tools:layout="#layout/patient_banner" >
</fragment>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_banner" >
<LinearLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
<fragment
android:id="#+id/footer"
android:name="com.apps4care.mycarerecord.fragments.footerFragment"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_alignParentBottom="true"
tools:layout="#layout/footer">
</fragment>
</RelativeLayout>
I then add a number of fragments into the that have the following layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/documentFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/tvsectionHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:text="Section Heading Text Goes Here"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge" />
<WebView
android:id="#+id/wvsectionHTML"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvsectionHeading"
/>
</RelativeLayout>
This gives a screen that looks like
My question is in three parts :
1) Where did the background color come from on the TextView. It is not set in the XML layout file or the code.
2) Why is the background color on the TextView not consistent. The bars lower down the screen are lighter, especially in the horizontal centre of the screen.
3) The Scrollview content is meant to stop above the "footer" fragment but it does not, the bottom of the content on the Scrollview is hidden behind the "footer" fragment.
The background for the TextView comes from it's (default) style which is transparent.
what you are seeing is the default background of activity in the Holo light theme. you can change it by overriding it in your theme, or setting a background color to the relative layout in you main layout file
The TextView colour is consistent, but it the colour of your background page, the default colour, which has a glow towards the bottom (it is the page's default formatting). This happened to my application too. Try changing the background of your page and see if the issue is still there, it should go away.