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

[TIMOB-20363] Fix Android: Buttons inside views appear on top of all other children #9679

Closed
wants to merge 1 commit into from

Conversation

maggieaxway
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-20363

Titanium.UI.setBackgroundColor('#000');

var window = Titanium.UI.createWindow({
backgroundColor:'#fff'
});
 
// create a main view which will contain the button and the view
var mainViewContainer = Ti.UI.createView({
top: 0,
left: 0,
right: 0,
bottom:0,
backgroundColor: 'red'
});
 
// create a view which will obscure the button
var shouldObscureButton = Ti.UI.createView({
top: 0,
left: 0,
width: 200,
bottom: 0,
backgroundColor: 'blue'
});
 
// create a button which is wider than the obscure view
var button = Ti.UI.createButton({
height: 350,
width: 350,
left: 0,
backgroundImage: 'buttonTest.png',
backgroundColor: 'yellow'
});
 
// add the button to the main view container before the obscure view
mainViewContainer.add(button);
 
// add a view that should obscure the button after the button has been added
mainViewContainer.add(shouldObscureButton);
 
// add the main view to the window and open it
window.add(mainViewContainer);
window.open();

@build
Copy link
Contributor

build commented Dec 12, 2017

Fails
🚫

Tests have failed, see below for more information.

🚫

📝 Formatting reported as incorrect on the following files:

  • android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIButton.java
    You can fix the formatting by running: npx clang-format -style=file -i <filepath>
Messages
📖

💾 Here's the generated SDK zipfile.

Tests:

Classname Name Time Error
ios.Titanium.Network.HTTPClient callbackTestForGETMethod 0.171 onreadystatechange@file:///Users/build/Library/De

Generated by 🚫 dangerJS

@maggieaxway maggieaxway added this to the 7.1.0 milestone Jan 3, 2018
@jquick-axway
Copy link
Contributor

I've tested this and noticed this removes the button's drop-shadow effect, which we don't want.

I'm pretty sure setting a Titanium view's elevation property to a value greater than zero will have the same z-ordering issue buttons have as well. So, this is a much bigger problem.
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.View-property-elevation

I'm not sure what the correct solution to this is. We need to use Android elevation feature to show the drop-shadow effect. So, I'm curious if we need to something like the below?

setTranslationZ(-getElevation());

This requires some experimentation.

@maggieaxway
Copy link
Contributor Author

@jquick-axway Hi I couldn't reproduce the button's drop-shadow effect even before the code change. I did some experiments, it seems only affecting the Z so that the layers. I have been looking into the source code but couldn't figure out where went wrong. :(

@jquick-axway
Copy link
Contributor

Closing since this change will remove the button's drop-shadow on Android 5.0 and higher. We need to find an alternative solution.

@hansemannn hansemannn removed this from the 7.1.0 milestone Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants