Reputation: 24583
I have a multi pane view: much like this:
The way I got this is by using elevation:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="4dp"
android:background="@android:color/white">
That scroll view is the detail view on the right. Android is assigned a darker background on my list view on the left to 'show' the elevation. Which is great, view looks perfect. However I want to highlight the selected item in the list.
List View:
Selected state:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/some_color" android:state_activated="true"/>
</selector>
My problem is I need to define some color and I want to make it a little darker than the color of the items in the list. However I am not 100% sure what that color really is.
Can I find that by debugging? Or better yet does anyone know what elevation is really doing to that views color?
Upvotes: 3
Views: 141
Reputation: 4136
Android isn't actually coloring the background differently based on elevation; the only effect an elevation attribute has is showing a shadow on 5.x devices. It just looks darker because you gave the ScrollView
a white background and the default background of an Activity is an off-white color. If you want to determine that color, I'd recommend simply taking a screenshot and using an app to see what color those pixels are; I find Color Picker works very well. If you want that background color to be consistent everywhere, I'd manually set your ListView
's background to that color.
Upvotes: 1