Android: Overriding the scrollbar drawable in an application - android

Is there a way to replace the scrollbar drawable in an application (i.e. I have a customized scrollbar view that I would like to use instead of the default gray scrollbar that comes with the Android framework). I looked through I believe all of the android attributes and none seem to support it (at least the simplest way I know how which I would assume would be setting a drawable to some android attribute).
If not and say it requires a change in the framework, where would I start looking for it (in the framework)?
Thanks
MB

Custom scrollbar thumb:
android:scrollbarThumbHorizontal="..."
android:scrollbarThumbVertical="..."
Custom scrollbar track (scrollbar background):
android:scrollbarTrackHorizontal="..."
android:scrollbarTrackVertical="..."

Related

No shadow on absolutely positioned View/Image?

I did a materalistic designed "Add" button on my Android-primary react-native app. While I used elevation style property as a primary source for shadows in the rest of the elements, I've discovered that it stops working when applied to an absolute positioned element. (Which I partially understand probably because absolutely positioned element ignores the general layout rules, but still, a shadow should work).
As far as I know, Android gets elevation and iOS gets their respective shadow properties.
I'd like to have this:
but I 'm getting no shadow once I set the element's style as absolute (in the bottom right corner).
Am I missing something or is it not working yet?
Simply, there is no current shadow support for Android in React Native yet and I think you are on the right track to use elevation way to achieve this. But it should only work for Android 5.0 or above.
Alternatively, you can try this module (https://github.com/879479119/react-native-shadow). It works for me.

Does elevation not work within Android Home Screen Widgets?

Tried all sorts of different ways to do this but not matter what view I apply an elevation to (such as android:elevation="10dp") it does not render correctly on a Home Screen Widget.
Is this a known limitation, that home screen widgets do not support elevation. I am running this on an Android L device so its should not be a compatibility issue.
If this is impossible I figure I could use 9-patch or layer-list drawable to achieve a similar but not as good effect.
I've played with all widgets I have on my phone (both with Nova Launcher and Nexus 5 stock launcher, which is Google) and none of them have this feature, even Google apps (excluding Google Now!).
I've added app:elevation="10dp" on my widget and I think that it is not possible to have this feature on Widget directly, without playing with code and fantasy.
If you really want a widget that include elevation design, just "copy" the style of Google Now widget.
I suppose that they have a transparent layout (the black parts on image) wich contains another layout (grey) with elevation and grid filled with CardView with elevation too.
Let me know if you want an example code.

android lollipop ViewGroup child hierarchy changes?

I have an app that has a minSdk of 15 and I'm working out all the bugs that came with the lollipop upgrade. Our software is very complex and it dynamically creates views using custom ViewGroups and then an array of elements that are explicitly sized and placed inside the group. I'm running into an issue where for example I'll have a ViewGroup and the first child object is a Button...this button is sized to fill the view (not clickable). The second child is a FrameLayout containing a single view. This single view is a video object. In all prior versions of Android this works just fine. The FrameLayout is layered over the button (that is acting as a background) and the video is inside the framelayout. You can interact with the video without any issues.
Something changed in lollipop - suddenly, even though the button is showing up as the 0 index element, it is laying OVER the rest of the children...so I cannot get to the video underneath. If I remove that button element, the video renders and plays just fine...I have no issues interacting with it.
I ran the app in UI Automator Viewer just to make sure I was really setting up the UI as I expected (keep in mind the entire view is dynamically rendered at runtime using image/video assets and xml config files).
I'm not able to share code since this is proprietary software, but I am working on a little test project to see if I can manually recreate the issue with static objects. Once I get that up and running I'll be sure to update this ticket. For now, here is a screenshot of the hierarchy:
https://goo.gl/photos/a8on9CJDnN66XYnV6
Notice the highlighted object, this is the custom ViewGroup, the children below it are what I am describing above.
Does anyone know of a change in Lollipop that would effect the ordering of things? I found earlier that if you have a disabled object but don't have a disabled state drawable assigned to that object it would become invisible, previous versions just used one of the other state drawables..okay that makes sense and it was very easy to fix, but this object is not invisible...so it must be something different.
Any direction would be greatly appreciated.
~A
UPDATE -- FIXED
With the help of #alanv and #BladeCoder I figured out this functionality was due to the new elevation feature of Material design. I was able to fix my particular issue by first checking what version of android the device was using, and if lollipop, I just add this new property to the button:
android:stateListAnimator="#null"
This prevents my explicit child hierarchy from being overridden by the OS.
Lollipop introduced elevation as a way to position the elements on the Z axis and cast shadows between them depending on their difference of elevation.
Enabled buttons have a default elevation of 2dp (and it increases when you press them). So, your button has a higher elevation than the FrameLayout (0dp by default) so it will be drawn on top of it.
Disabled buttons have an elevation of 0dp. That's why disabling the button solved your issue.
Using buttons as backgrounds looks like a bad idea (why not setting a custom Drawable background on your FrameLayout instead?) but if you really need that, you can disable the button like you did and, just to be sure, enforce its elevation to 0dp. Another workaround is to increase the elevation of the FrameLayout but then it may cast a big shadow under Lollipop if it has a background, and maybe that's not what you want.
Okay, UPDATE! I figured out how to fix the issue, although I'm still not sure (even after pouring over the diffs between several classes in grepcode) what changed in lollipop that is causing a change in how this works.
If the button is enabled...and you are placing it using something equivalent to AbsoluteLayout (We have our own ViewGroup we created called Explicit layout, but it does pretty much the same thing as AbsoluteLayout), it will always be on top of anything else in the stack that isn't also a button of some sort (at least that's what I'm finding...I didn't test through every possible widget).
Setting the button that is acting purely as a background image to enabled=false solves this issue. I know, it doesn't make sense that we use Buttons as background images, but our code uses it for dynamic element creation so there are many possible states and uses for each element.
Anyway, not sure if anyone else would even run into this issue, but just in case you do...here it is.
Thanks!

How can I change the colour of the toolbar in a FireMonkey mobile application

I'm using Delphi XE7 for developing mobile application. And how can I change the colour of the TToolbar component in Firemonkey mobile application? I can not find the option in the Object Inspector. Is there any other option to change the colour of this component. And I'm targeting Android platform.
Method #1: In Firemonkey most components can be contained within most other components. Place a TRectangle inside of your TToolBar component. Align it to Contents. Change the Fill color to the color you want. Change the Stroke.Kind property to None. Done.
Method #2: You can also do this by modifying the style. Drop the TToolBar on the form. Right click it and select Edit Custom Style.... You should see a toolbar1style1: TStyleObject in the Struction window. Find TRectangle in the Tool Palette. Drag and drop the TRectangle onto the toolbar1style1 line in the Structure window. It should add a TRectangle to your style. Set the Align to Contents. Set the Fill color to what you want. Set the Stroke.Kind to None. Apply and Close. Done.
It will create a custom TStyleBook on your form and your Toolbar should be the Fill color. This may be a less cluttered way than the first method. But could conflict with loading Premium styles into the TStyleBook. Therefor I think the first method is more forward compatible and more maintainable.
TintColor is the property that you are looking for
If your target is the Android platform, I think you can use the TintColor property.
I have tested the behaviour in Delphi 10.1 Berlin, and it does work correctly.
Please note that the TintColor property is currently only available for mobile platforms (iOS and Android).

Default view padding

I'm just starting to learn android and i had a doubt concerning to view padding. Referring to What controls the default padding between views? , Is the padding included in the size we specify to the view ? All help appreciated!
EDIT: Also does a layout add padding to itself by default ?
In the question you linked to, the padding is caused by the button's background being a nine-patch and having some transparent borders in it. Since the "padding" is part of the background resource, it is include in the image size and you don't need to do anything to make it show up.
However, if you are creating your own Views, or changing the background or foreground resources of the system provided Widgets, you may want to use the android:padding* attributes to specify the various paddings.

Categories

Resources