There are some margins with NavigationBar - android

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"
// .... />

Related

Android: RecyclerView padding preventing full screen experience

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?

Shadow on floating action button

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"

How can i set an image to be in the bottom left corner of an activity AND in the background

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>

Textview background - what's setting it?

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.

How to get a view larger than its parent?

I have a top bar with a show/hide menu button. I would like to define the top bar, the button and the menu in the same layout.
I tried a layout with the height of the top bar, but the menu is clipped and is not visible. Is that possible to have a view larger than its parent. Otherwise, what's the standard way to do that?
For your question: Yes It's possible. Simple example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f"
android:layout_marginLeft="-50dp"
android:layout_marginRight="-50dp"
/>
</LinearLayout>
And ImageViewWidth == LinearLayoutWidth + 100dp.
Hope its help.

Categories

Resources