I am not able to make the menu item stay with the gray border when selected. The problem is the same as the link below:
Possible Solution
Although the colors of the item menu change, the background does not appear. I've read a lot of topics but i don't find a solution for this problem. I am using in my navigationView the following property:
app:itemBackground="?android:attr/selectableItemBackground"
I found a solution using StateListDrawable, the problem was in the property "?android:attr/selectableItemBackground", so I created my own and the problem was solved.
Related
I have seen questions about this previously but none seem to work for me.
I want to change the color of the material drop down, as seen here
I want to make the arrow black.
I have tried making a custom drawable and using that with dropDownSelector but it didn't show the arrow correctly. I have tried adding it as a style and it didn't work either.
Any ideas would be great.
Thanks
I have encountered the same problem as well. But i had some focus problems, because Spinner was inside ScrollView. I have solved the issue by implementing ListPopupWindow.
Here is great example how to implement ListPopupWindow :
I would like to reproduce the effect of appearance and disappearance of the action bar that carries the Google Application Now.
Exist there a library (GitHub project) to achieve this effect?
1) Initially, the action bar appears normally.
2) Then, as soon as you scroll down the listView action bar disappears.
3) And then, as soon as you scroll up the action bar appears again.
It's called Quick Return. See this blog post for details on the pattern. There is also a link to an implementation by Google developers.
Maybe this link can be usefull: it shows how to change ActionBar color while you scroll on layout. You want to achieve the opposite one, so you have to change a little the code. Personally i didn't try this code, but the blogger is a very good developer!
If this has already been asked, forgive me. But I'm wondering if there is a simple way to adjust the transparency for ListView selection. I know how to change the color, but is there any attribute that allows to adjust the transparency? Or would you have to upload some custom background?
If by transparent you mean see-through, and by ListView selection you mean a single item of the ListView, then its called alpha. The link should show you the info for the XML, but you can also set it using setAlpha(), which is accessible to any View.
I created a ListView in Android, and a corresponding ListActivity. Each individual item in the ListView has just one TextView (I plan to add an image and a CheckBox later).The ListActivity overrides the onListItemClick to perform certain tasks on click of any item on the list.
Heres whats happening -
When I first tried clicking on any item, nothing happened.
I then tried setting the properties "Focusable" and "Focusable in Touch Mode" to false for the TextView, as mentioned here, here and here. The List items started recognizing clicks, but only when I clicked somewhere away from the TextView. Whenever I tried clicking on the TextView or anywhere near it, it did not work.
I also tried changing various attributes like Clickable, but nothing has worked so far.
Any idea what I could be doing wrong ?
Thanks
After playing around with virtually every attribute in my TextView, I finally found the reason why it was not working. It was because of the attribute android:inputType="text" in my TextView. I'm not sure why I added that piece of code (I probably copied the TextView from one of my other applications), but removing it solves my problem.
Class which will listen clicks on ListView should implement interface AdapterView.OnItemClickListener
I have a custom spinner dropdown xml file in /res/layout/:
spinner_view_dropdown.xml:
<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/spinner_item_dropdown"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/transparent"
style="#style/spinner_item_dropdown" />
I'm setting the spinner dropdown via java:
// "Spinner", aka breadcrumbs
Spinner spin = (Spinner) findViewById(R.id.breadcrumb_dropdown);
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.breadcrumb, R.layout.spinner_view);
adapter.setDropDownViewResource(R.layout.spinner_view_dropdown);
spin.setAdapter(adapter);
// /"Spinner"
Unfortunately, a white background still exists on the spinner popup regardless if I set the background to transparent.
How do I fix this?
You can override the style for the dropdown, and the dropdown item by using a Theme in your app that inherits from one of the Android themes, then override the
android:dropDownSpinnerStyle, or android:spinnerDropDownItemStyle, and even the android:dropDownListViewStyle attribute of the theme, pointing to your own custom style instead of the Android style that is defined in their theme. I created a fully customized spinner this way, with a transparent button AND dropdown. I even got rid of the dropdown list dividers, and set my own spacing for the dropdown items when I built the tablet app for Fandango (take a look at the sort movies spinner on the main page of the app).
Everything in Android is customizable, you just have to know where to look. ;-)
Try setting on the spinner this:
android:popupBackground="#android:color/transparent"
The layout you're defining is only used for an entry of your drop-down, not the drop-down itself. So setting the background to transparent won't have any effect on its background. But even if it would, setting the background to transparent would still have no effect, because a TextView (actually I believe any view) has a transparent background by default.
That being said, the right question would be: can you provide a custom layout for an entry's parent view (which is probably a List)? As far as I know, the answer is no, unfortunately.
Try
android:cacheColorHint="#00000000"
to get transparency.
I dont know if it works for you but there is a post
http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html
that explains why the moving parts of a list appear in the background color.
Maybe its the same issue with your spinner.
It's a bug in 1.5 I think, see here
http://www.symsource.com/index.php?view=article&id=418&option=com_content&format=pdf
Run it in a 1.6 emulator or device, does it still stay white?
I actually came here looking for an approach to this, I suspect this may involve manually writing to the canvas or something like that.
Any ideas.
P.S. Accidentally posted when I thought I was logged in, anyone know how to get rid of the anonymous comment? Maybe an admin could fix this?