I just started to use the new Deisgn library from Google : 'com.android.support:design:22.2.0'
I use the FloatingActionButton and I have a small issue between Android below 5.0 and over 5.0.
Watch the screenshot :
Android 4.4 :
Android 5.0 :
As you can see, on Android 4.4, there is a margin around the FAB. I think this is for displaying the shadow. But IT'S OVERSIZED !
So is it a bug (or a forget of Google) or just the normal behavior ?
The xml of the view hosting he fabs :
<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="fr.freemo.freemo.activities.ListFreemoCityActivity">
<include
android:id="#+id/toolbar"
layout="#layout/view_toolbar" />
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
</FrameLayout>
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/margin_fab"
android:layout_marginRight="#dimen/margin_fab"
android:elevation="#dimen/fab_elevation_lollipop"
android:src="#drawable/ic_action_new"
app:backgroundTint="#color/color_app"
app:fab_type="normal" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/fab_add"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/margin_fab"
android:layout_marginRight="#dimen/margin_fab"
android:elevation="#dimen/fab_elevation_lollipop"
android:src="#drawable/ic_map_white"
android:tint="#color/color_app"
app:backgroundTint="#color/white"
app:fab_type="normal" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_display_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/fab_display"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/margin_fab"
android:layout_marginRight="#dimen/margin_fab"
android:elevation="#dimen/fab_elevation_lollipop"
android:src="#drawable/ic_action_list"
android:tint="#color/color_app"
android:visibility="invisible"
app:backgroundTint="#color/white"
app:fab_type="normal" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_display_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/fab_display_list"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/margin_fab"
android:layout_marginRight="#dimen/margin_fab"
android:elevation="#dimen/fab_elevation_lollipop"
android:src="#drawable/ic_view_module_white"
android:tint="#color/color_app"
android:visibility="invisible"
app:backgroundTint="#color/white"
app:fab_type="normal" />
</RelativeLayout>
It was an issue (check a bug report created by me: https://code.google.com/p/android/issues/detail?id=175330) and should be fixed in the future release of the support-design library.
Its a bug for API 21. You can make arrow visible by removing some margin.
Here is the way You can solve it and after testing on different devices it seems to work:
https://stackoverflow.com/a/31337162/3173384
Edited
Bug has already been fixed. Just update all support libraries to v 22.2.1
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
This has been specified to not being an actual bug. Instead, this is the expected behavior.
Quoting a google dev answer:
This isn't a bug and is working as intended, in the sense that it's something that which is completely unavoidable. Within a CoordinatorLayout we have some control and can detect certain situations (edges) where it can offset the FAB. This is a hack though.
If you don't like it, set elevation to 0dp and be done with it.
As someone other stated here, we should define
xmlns:app="http://schemas.android.com/apk/res-auto"
app:borderWidth="0dp"
app:elevation="0dp"
or, even better, define your elevation in dimens.xml based on the API version you are working with.
Most common case would be:
<!-- dimens.xml(v21) -->
<dimen name="custom_fab_elevation">#dimen/fab_elevation</dimen>
<!-- dimens.xml(lower) -->
<dimen name="custom_fab_elevation">0dp</dimen>
Related
I am using this library to achieve expandable cards and it works fine except for two major concerns viz:
It requires the min api level to be 21 and previously my min api level was 16. Will this work well on lower devices. There's an option to override this in the library's manifest file but I don't think it's a good idea.
I have layout like below which contains another layout with a textview but the text is not showing fully, only the first line is visible. Here's the layout:
<com.alespero.expandablecardview.ExpandableCardView
android:id="#+id/focusCardLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/metaCard"
android:layout_marginBottom="10dp"
app:expandOnClick="true"
app:inner_view="#layout/session_inner_card_focus_pts_layout"
app:title="Focus Points" />
and the inner_view layout:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/focusPointsTV"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
android:text="You cannot win matches without scoring points so it's important your players can shoot accurately."
android:textSize="18sp"
android:padding="10dp">
</TextView>
Is this a fault in my layout or the library. I have set input_type to short/long message, still no effect.
Is there other means of expanding-collapsing cardviews android? Thanks.
I tried your code, and I think your issue come from the library.
I know a lib that resolve your issue as well, that is this library
<!-- sample xml -->
<com.ms.square.android.expandabletextview.ExpandableTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
android:id="#+id/expand_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
expandableTextView:maxCollapsedLines="4"
expandableTextView:animDuration="200">
<TextView
android:id="#id/expandable_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="16sp"
android:textColor="#666666" />
<ImageButton
android:id="#id/expand_collapse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_gravity="right|bottom"
android:background="#android:color/transparent"/>
</com.ms.square.android.expandabletextview.ExpandableTextView>
It's work for me and I hope it will help you too.
I want to add fragments to my application and I installed the xamarin.android.support.v4 and other required but it gives an error
error: package android:support.v4.view or app or content etc. does not exist.
I have tried on a blank project with the same results.
I am using Android 7.0 and the latest support library.
For now,i want to also add RecyclerView and CardView
To use these two controls, you need to install the Xamarin.Android.Support.v7.RecyclerView package and Xamarin.Android.Support.v7.CardView in your project. When you install the Xamarin.Android.Support.v7.RecyclerView package using Nuget, the Xamarin.Android.Support.v4 package will automatically be installed.
And you can use RecyclerView like this:
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
And so is the CardView:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:scaleType="centerCrop" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Caption"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
You can refer to the official document RecyclerView of Xamarin for using and customizing RecyclerView in Xamarin.Android applications.
If there is still problem, could you please provide a minimal reproducible demo, so can we continue to investigate this issue.
As the title says, my FloatingActionButton has some weird lines coming out of it only on 4.4 or lower. On Lollipop it works fine.
This is a picture of the issue:
The play image doesn't have those lines in it. My xml:
<android.support.design.widget.FloatingActionButton
android:id="#+id/play"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="#drawable/ic_av_play_arrow"
app:borderWidth="0dp"
app:elevation="6dp"
app:layout_anchor="#+id/image"
app:layout_anchorGravity="center_vertical|right|end"
app:rippleColor="#color/color_primary_light" />
So what am I doing wrong?
EDIT: goes away if I set my elevation to 0dp so I think I'll do that just for older phones
Your problem here is that you're making the FloatingActionButton an unexpected size. The FloatingActionButton in the support library only supports two sizes, and it must be set using the fabSize attribute.
You should change:
<android.support.design.widget.FloatingActionButton
android:id="#+id/play"
android:layout_width="48dp"
android:layout_height="48dp"
to be:
<android.support.design.widget.FloatingActionButton
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
If you want a smaller version:
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="mini"
Source: http://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html
I wanted to implement a floating action button in android studio and I followed all the steps: Adding dependencies, adding the xmlns to the layout and making the floatingbuttion in the xml as follows:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.clans.fab.FloatingActionButton
android:id="#+id/fab"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="bottom|right"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
fab:fab_colorNormal="#color/primary"
fab:fab_colorPressed="#color/accent"
fab:fab_colorRipple="#color/primary_dark" />
</FrameLayout>
but in the preview I got a gray, empty square. What am I doing wrong?
I am not sure, but I think you have to include a src
Please reply if it helped you!
<android.support.design.widget.FloatingActionButton
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/fab"
android:src="#drawable/abc_ic_search_api_mtrl_alpha"
android:layout_alignBottom="#+id/recyclerview"
android:layout_alignRight="#+id/recyclerview"
android:layout_alignEnd="#+id/recyclerview" />
Please add the code "app:borderWidth="0dp" as property.
Background
I have a card-like UI on my app, which uses a RelativeLayout.
The problem
Recently I've discovered that on at least one device ( or rom, or andorid version), when I switch to an RTL language (such as Hebrew), everything got messed up.
This has happened only on LG G2 with Android V4.2.2 .
Here's what I see:
If you compare it to the screenshots of the app, you can see this is not how it should look like.
That's even though on all Android devices that I've checked, and on all emulators, I've never seen it (even when switching to Hebrew).
What I've tried
I've tried to fix it by using a GridLayout instead, but that wasn't working well (link here).
I've also tried to use a LinearLayout, but considering there might be issues with it, I've used LinearLayoutCompat instead. It works, but it's not recommended to use so many.
Another thing I've tried is to port the RelativeLayout of Android source code, but this gives me a lot of warnings and errors that are quite hard to handle.
Here's the original XML of the layout, BTW (I've removed the irrelevant stuff, to make it shorter) :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants" >
<ImageView
android:id="#+id/appIconImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="#android:drawable/sym_def_app_icon" />
<LinearLayout
android:id="#+id/appDetailsContainer"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/appIconImageView"
android:layout_toLeftOf="#+id/overflowView"
android:layout_toRightOf="#+id/appIconImageView"
android:layout_toStartOf="#+id/overflowView"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:text="label" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="description" />
</LinearLayout>
<ImageView
android:id="#+id/overflowView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#android:drawable/sym_def_app_icon" />
<ImageView
android:id="#+id/isSystemAppImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#android:drawable/sym_def_app_icon" />
</RelativeLayout>
The question
As I use RelativeLayout, how can I port the code from the official source code of Android?
Is there maybe a library that does it?