I have a dialog containing a dynamic ListView. I'm trying to style it similar to the Android L notifications center but I can't seem to do so.
My dialog window background is already transparent and the ListView content is set up but I can't seem to add transparent dividers to it. When I change my listview's divider color to transparent, it completely disappears removing the gap in between. After manually setting a divider height, it returns but it's not transparent. Instead, it's some sort of dark blue-ish transparent color.
My code for this is fairly simple:
// Create ListView
ListView mList = new ListView(context);
mList.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
// Create dialog base
final Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
mDialog.setContentView(mList);
mDialog.setCanceledOnTouchOutside(true);
mDialog.setCancelable(true);
// Add listview content...
// ...
// Apply dividers and content
mList.setDivider(new ColorDrawable(R.color.transparent));
mList.setDividerHeight(72);
mList.setAdapter(mAdapter);
.
How would I go on to styling it like it? My only issue with this is the lack of transparent ListView divider.
This is what I'm trying to achieve:
I ended up achieving this effect using card images with transparent margins embedded in them.
Related
I want to set the opacity of each and every Listview row using android:alpha. I tried doing so but the row doesn't get the transparent background. I have a colorful background of the layout and I want a glass or transparent type of row of the ListView. How can I do it?. I don;t want to use any adapters for this. So please suggest some simple methods.
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
If you are set opacity of listView us below Code
android:background="#80ColorCode"
I have an Activity with a ListView, I set the background image to the view programatically.
When I scroll down my list, the background image turns to white ( because my theme is Theme.Light.NoTitleBar).
How can I make it scroll with the blue background intact?
If the above point works, how can I change the text color of ListView to white instead of black?
Normal ListView
Scrolling ListView
Pressing ListView item
Use the attribute android:cacheColorHint="#000000" in ListView Tag
Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this
android:textColor="#FFF" //or #FFFFFF for white
add a attribute on the ListView Tag
android:cacheColorHint="#00000000"// setting as a transparent color
This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"
Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html
You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)
Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.
I want to create context menu as follows , i am sure this is not traditional the context menu , its a kind of alert dialog which is being customized.
I tried following code but it adds the footer end of the ListView not to the dialog / context menu reference thread is ContextMenu with footer view (to add checkbox for 'make default' option)
dialog2.getListView().addFooterView(new CheckBox(this))
I have gone through the followig tutorial which has custom context menu , is it possible
to use this code to set a footer
http://www.tanisoft.net/search/label/Tutorial
I want following features , preciously the checkbox in the footer
EDIT
I reached to this part now there are only two issues
1) Dialog Title Icon
2) Dialog Bottom Blue Color ( which is a default
color of android )
and i don;t know how to achieve above two task
Here is my code to create dialog
contactDlg = new Dialog(this);
contactDlg.requestWindowFeature( Window.FEATURE_LEFT_ICON );
contactDlg.setTitle(contactStore.getContactName());
contactDlg.setContentView(R.layout.contact_dialog);
contactDlg.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.bottom_bar);
contactAdapter = new ContactAdapter(this,contactStore.getContactNumber());
modeList = (ListView) contactDlg.findViewById(R.id.contactDlgList);
modeList.setBackgroundResource(android.R.color.white);
modeList.setCacheColorHint(Color.WHITE);
modeList.setAdapter(contactAdapter);
contactDlg.show();
No need to do any thing special for this.This can be achieved easily by creating your own layout containg the list shown in this pic and the footer view in the dialog itself with thye color and style you want.Then just make the property of the dialog named "windowFrame" to be null by < item name="android:windowFrame">#null< / item>Also you can make a separate "theme.xml" in the "values" folder and define this and similar kinda properties in that file.In code, when you instantiate the dialog object, set this theme to it.The basic purpose of doing this is to achieve the total control on what to show and what not in the dialog you create.
I have a dialog with a custom theme:
final Dialog d = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
This makes my dialog background transparent.
Now the problem is if I let the normal theme(style.dialog) it is centered in my screen but now it has no layout and is in the upper left corner of my screen. Is there a way to programmatically center the dialog?
I didn't actually find a programatic solution to my problem, instead in my customdialog.xml I put the main layout into a RelativeLayout with fill_parent for height/width and then put the layout atribute centerInParent="true".
construct your dialog by extends Dialog,
override the style & content(by setContentView)
I am using the this code to have section/headers in list.
http://w2davids.wordpress.com/android-sectioned-headers-in-listviews/
I am setting the color with 50% alpha to list header and my window background color is transparent. So while scrolling header color becomes dark. Any idea how to overcome this.
and i have also set android:cacheColorHint="#00000000".
I had the same problem. I set the background color of the header view to the same background colour as the list's parent and it worked.
So I had a LinearLayout with a background colour of 'grey'.
The list is contained within this layout.
The list had android:cacheColorHint="#00000000" set in the XML and no background colour set.
The header view is loaded using LayoutInflater, inside my activity and set before the call to the list's setListAdapter.
The parent View (or main View) of the list header was also a LinearLayout with a background colour of 'grey'.
Hope this works for you.