How would I go about implementing a shadow like the one you see under the title bar? I know this can be done (see for example the app "Andlytics", where this effect shows on the bottom as well).
My best guess is that it's a banner image used as the background for the layout. But maybe there is a better way?
I looked through the images in the SDK's data/res folder and I found what is probably being used: title_bar_shadow.9.png . Errr, can't attach it here, but you should be able to find it in your android-sdk-location/platforms/android-N/data/res/drawable-hdpi/ folder.
I'm guessing it is probably achieved by using a 9-patch with a gradient on the top edge and corners as the layout background. I don't know of any better way, but this should be pretty simple to implement.
Take a look at this question: Custom ImageView with drop shadow
Or we could use a gradient - and Android seems to be going that way.
In later versions of the platform SDK code, the title bar image is replaced by action_bar_divider.xml.
The divide is nothing but:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffe1e2e4"
android:endColor="#ff95979a"
android:angle="270" />
</shape>
You can use it in an image view just below your title bar.
Related
thank you for answering me
I just want to know how i can make the shadow below this card
I already tried several ways like Elevation... but it didn't work for me.
I searched a lot about it and I found that website :
Shadow generator
But i'm wondering if there is another way, using xml or anything else.
You are half right in that elevation is required for a shadow effect.But note this is only applicable to view that are not buttons. For buttonViews you can add a statelist animator that handles the properties of a button for all its states.Also if you are using something like a textView that does not have any margins you might as well use a background to show the shadow as follows:
android:elevation="30dp"
android:background="#000"
For other views, this means simply adding the elevation attribute as shown above and the background is not required
This link will help:
How to provide shadow to Button
I'm trying to use a listview in my application with a gradient from the bottom.
I do not want to use the gradient in the background, I like to use it in the listview.
To try to explain better, I attached a picture of what I want.
The background will show images that will change.
I searched a lot and made several tests, but without success.
I appreciate any help.
Thanks and regards
Android has something built in for that. It is called fading edge. The two XML properties are android:fadingEdgeLength and android:requiresFadingEdge. If you were hoping to have the image gradient change, I don't think they are dynamic.
I've been trying stuff and searching for the last couple of hours and got no where so I thought I'd ask here.
Basically the Honeycomb version of Gmail has a listview on the right for it's message list and when you scroll the listview the items go under the actionbar which appears to have some form of gradient on it with #00FFFFFF at the bottom going up to #FFFFFFFF at the top giving the impression of the items fading out.
But they important thing to notice here is that the SCROLLBAR on the listview never goes underneath the ActionBar! and the default top position for the listview is underneath the scrollbar.
I've tried to implement a similar style layout for my app with a scrollview that scrolls underneath the actionbar which has an alpha set on it, it looks all nice and well but the scrollbars go underneath as well! :( and it makes it look a bit weird, it's not a nice option.
I've achieved what I have so far by using
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
and
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
which is a an XML drawable that simply has a color of #BB000000 (no gradient just yet)
this is the current effect, the scrollbar can be seen underneath the actionbar :(
this is the desired effect with the scrollbar never going into the actionbar but the content does scroll up underneath it
Edit: I think this probably uses something custom in Google and have all but given up figuring it out
call this before super.onCreate(savedInstanceState); in onCreate of your activity
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
More: http://developer.android.com/reference/android/view/Window.html#FEATURE_ACTION_BAR_OVERLAY
I can't see an easy way of doing this but I have come up with two possible solutions. There could well be a much better option that I couldn't see obviously.
The first and easiest, is to create a 9patch background file for you ActionBar that has an expanding gradient area and a fixed opaque area at the right hand side, the same side as your scroll bar. This way the scrollbar would still go under the ActionBar, but it would be hidden. However it would have the affect of the scrollbar disappearing / getting smaller.
Another option would be to edit the scrollbar thumb in the xml like this:
<ListView android:scrollbarThumbVertical="#drawable/YOUR_CUSTOM_THUMB" ></ListView>
Then create a scrollbar thumb with a transparent offset at the top.
Thinking about it I think the second option is probably the best to go for and will give you the best result. I realise it's a pretty crappy hack. Looking into a code way of doing it, I think you would have to extend a number of classes and override a load of methods.
simply use:
getActionBar().setBackgroundDrawable(null);
So I found this really nice WheelView here that has been mentioned here before. I tried using it but I hit a few problems, and don't know what am I doing wrong. So what I did is link the src folder like it has been done in WheelView-demo app. It didn't work then, but to make it work I had to link a gen folder also and copy layout_bg.xml over to my res->layout folder from the demo app.
After that I created my two arrays of data that will be shown (text) and when I run it I get this.
image
For background of both wheels it uses my icon.png files, and I just want it to be white as it is in the original app. Also the selection bar is not transparent so I can not see the selection.
Any ideas what to do? Thanks for the help.
Ok, I fixed it, but I think it might not be the right solution :)
So there is a file called layout_bg.xml whre the bar with the selected value is defined, colours wise. These are the contents:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FF000000"
android:centerColor="#FF000000"
android:endColor="#FF777777"
android:angle="90" />
</shape>
So to fix it I replaced centerColor="#FF000000" with centerColor="#00FFFFFF". You could write all zeros, but this way it looks nicer. Anyway what is still puzzling me is that in the android reference, it says that first two digits represent Alpha channel, FF being opaque and 00 being transparent, but I am not sure that this kind of mistake would be in this code that I downloaded?
I am writing an Android application at the moment, no knowledge of java what so ever, except what I have learnt in the last 5 hours. I've managed to implement a two screens and a nice looking layout.
I have three questions:
How do I set the Action Bar on Honeycomb to be transparent like in the Google Maps application? I want to be able to partially see the background graphic through it.
What code to use to empty five edit texts and a textview on button click? I've read something about a viewgroup, but I have no idea how to implement that...
I have a linearlayout with a tablelayout centred horizontally and vertically inside it, and eleven table rows in that. How do I set a partially transparent black as a sort of fill colour for the tablelayout without ruining the background of the linearlayout? Every time I try to set a fill colour it blacks out the entire background image of the layout surrounding it as well.
Plain english would be preferable because I am so new to this.
Thanks heaps for any replys, have a great day.
For the first question, I think you can do like below:
In the onCreate() method, before the setConentView() add:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
The Android system will automatically set background fill the whole screen.
create a transparent sharp "mysharp.xml"like below:
<?xml version="1.0" encoding="utf-8"?>
<shape>
<solid android:color="#55000000" />
</shape>
set the action background
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.mysharp));
you can also declare action bar overlay in xml by
<item name="android:windowActionBarOverlay">true</item>
just like here http://developer.android.com/resources/samples/HoneycombGallery/res/values/styles.html
Answer to your 1st question: You can implement a theme on the HoneyComb action bar. Check this link for more info. The color would be something like this: #29000000.
The first hex 2-digit(#29) represents alpha channels of color and set opacity. If value is “00” that means 100% transparent. if value is set it will be opaque, it can be any value in 00 to FF.
More links on styling the Action Bar:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
Example project is to be found here:
http://p-xr.com/customizing-the-action-bar-in-honeycomb/
In my Android 3 application I used
// Makes Action Bar Transparent
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
actionBar = getActionBar();
actionBar.setBackgroundDrawable(null);
// END
and now the action bar is 100% transparent, Except for the stuff I add to it of course :)
Cheers