Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - elevation style property does not work without backgroundColor. #10411

Closed
niagr opened this issue Oct 16, 2016 · 5 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@niagr
Copy link

niagr commented Oct 16, 2016

Issue Description

The elevation style property on Android does not work unless backgroundColor has been specified for the element.

RNPlay example

With backgroundColor applied to instructions element:

with-background-color

Without backgroundColor applied:

without-background-color

Steps to Reproduce / Code Snippets

  • Create a View
  • Add elevation style property - notice it has no effect
  • Add backgroundColor stype property - notice elevation is now applied

Expected Results

Unless I'm missing something elevation should get applied regardless of whether a view has a background color or not.

Additional Information

  • React Native version: 0.33
  • Platform(s) (iOS, Android, or both?): Android
  • Operating System (macOS, Linux, or Windows?): Linux
@leeight
Copy link
Contributor

leeight commented Oct 20, 2016

Checkout this question on Stackoverflow: http://stackoverflow.com/questions/27477371/android-elevation-not-showing-a-shadow

@leeight
Copy link
Contributor

leeight commented Oct 20, 2016

cc @janicduplessis @satya164

How about add a new style property such as outlineProvider (https://developer.android.com/reference/android/view/ViewOutlineProvider.html), just like what we did in Libraries/Components/View/ViewStylePropTypes.js

  /**
   * (Android-only) Sets the elevation of a view, using Android's underlying
   * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation).
   * This adds a drop shadow to the item and affects z-order for overlapping views.
   * Only supported on Android 5.0+, has no effect on earlier versions.
   * @platform android
   */
  elevation: ReactPropTypes.number,

  outlineProvider: ReactPropTypes.oneOf(['bounds', 'padded_bounds', 'background'])
<View style={{elevation: 10, outlineProvider: 'bounds'}}
  ...
</View>

@leeight
Copy link
Contributor

leeight commented Oct 21, 2016

Looks bad

<View style={{alignItems: 'center', marginTop: 50, elevation: 10, outlineProvider: 'bounds'}}>
  <Text>Hello World</Text>
</View>

image

@Kishanjvaghela
Copy link

@niagr I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview

@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants