Title of custom dialog always maxes out width - android

My problem is identical to: Android: Custom Dialog has wrong dimensions
The solution for that was to disable the dialog title, which does work. The problem is I want the dialog title. I am positive the mere presence of the title causes all the extra width: if I set all child views to a known width (say 100 dp) it is still far too wide. As soon as I remove the title it's just fine, but again, I want the title! This has to be a bug, right?
Any ideas? I'm aware I can create a fake title, but I'd rather not.
Thanks!
P.S. - In case it matters (and I don't think it does) I am subclassing android.app.Dialog, not DialogFragment. Subclassing vs using the builder has no effect.

I know you would like to figure this out without disabling the Dialog Title, but it's really not an issue if you do that. Just add another view to your dialog layout, at the top, for your title.
No shame Mark! No shame!

Related

Android AlertDialog: How to hide the activity behind it?

I'm looking for a way to hide the underlying activity of an AlertDialog.
I tried to set a solid overlay color but it looks like there are no default methods for doing this. Is there a way to do this without creating a new activity with a solid background color that then fires the dialog?
I couldn't find anything other than doing it by firing a whole new activity on StackOverFlow, google, the android documentation and the AlertDialog API page but this seems like overkill.
Ideally I'm looking for something like alert.setOverlayColor(int color)
Create a custom layout for the Dialog with height and width as "match_parent". Use the area required by dialog and put a solid background in the top level.

How to use ActionMode.setCustomView so that it takes as much space as it needs?

Background
In my app, I have a custom view, which is a title (TextView) that can be clicked (and have the background of a spinner, in order to show it's clickable) , as such:
The problem
I tried to add another action bar menu item, but now it makes the custom view take less space, instead of showing all of it, so the text gets truncated
What I've tried
I tried the next solutions:
setandroid:uiOptions="splitActionBarWhenNarrow" for the activity. This works, but it also mean that the upper action bar rarely has any content, so it's a waste of space.
I tried setting the width and/or minWidth of the custom view, but it didn't do anything.
I tried to make the textView have a marquee effect or multiple rows but it looks bad. I prefer the text to take as much space as it needs, and then have the rest of the action items.
The question
How can I make the custom view have as much space as it needs, and then have the other action items being shown ?
In the end, I used my own library that auto-resizes text (here) and set the layout params so that the width would be MATCH_PARENT .
It's not the solution I was hoping for , but it's also ok...
It will be this way on the next version of my app.

Create blue "tutorial" dialogs as in Android 4.4

I would like to create some "dialogs" like those shown in Android 4.4 for example when you are first shown immersive mode. The little arrow is important for me because I would like to have the dialogin different places on the screen.
This is what I'm talking about:
Do I need to create a custom AlertDialog? How do I move it around, can I use the coordinates of a View? I don't really know where to start. Are there any examples on creating this type of thing? I am not interested in using the ShowcaseView library as in my opinion has the "old" holo look.
You can get the coordinate of views using getLocationOnScreen(), make sure to call this after the views have been inflated (so, not in onCreate() of your activity) or else you will be returned default int values (i.e. 0).
You should probably create your own DialogFragment. Incorporate your own custom layout which contains the little bubble and the button. A Quick and dirty sample for the onCreateDialog() would have the following
Dialog dialog = new Dialog(getActivity());
// Get rid of the annoying alert dialog title bar
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// You must set the content view after requesting window features, not before.
dialog.setContentView(someView);
// Make the dialog full screen
dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//Dim the background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.argb(80, 0, 0, 0));
To incorporate the little arrow, you can try having variations of 9-patch images as the background of the little bubble. Another alternative would be to have an arrowhead and a bubble put into the same container, and setting the margin/padding between them to 0. Since you have the coordinates you can adjust the horizontal margins of the arrowhead accordingly. This is actually a pretty cool idea, I think I'll try my own interpretation of it this weekend.
I have actually been working on my own interpretation of the showcase library, Here is what i achieved. Much of the dynamic position changing should be the same I would think

Android - popup window or something else

I am currently developing an android app that displays a list view. When an item from the list view is selected I would like a small window to appear from the bottom of the screen. This window will not cover the entire list view, but take up a small portion of the bottom. On this window will be a few buttons and a progress bar.
My question is would the best way to achieve this be through a popupwindow or is there something else to better suit this?
Thank you for your help.
you could use a Dialog with a custom View (Android Custom Dialog example). Or you can forgo the concept of the pop-up and just "fake it" by adding your "pop-up" View into your normal layout but setting it as invisible. Then when you want to show it make it Visible and populate it with the appropriate data.
I think I understood what you meant. Do you use ActionBarSherkock? If yes, then there is a splitactionbar which is ususally located on the bottom of the screen, when the screen is small. It looks like this:
http://wptrafficanalyzer.in/blog/wp-content/uploads/2012/07/actionbar_menu_sherlock_splitactionbar.png
Is this what you meant? Let me please know.
Edit:
There is something called quick actions. This handels popups very well, but its not displayed on the bottom of the screen tough. But you might want to look at it:
http://londatiga.net/images/quickactions/quickcontact.jpg

creating popup dialog like facebook android app

I want to make popup dialog like in facebook app with pointing marker to the selection area.
here is an example how it should look like.
http://imageshack.us/photo/my-images/9/facebookandroid.png/
please help if you know something about it.
Thanks in advance..
May be your question would get solved from this
https://github.com/lorensiuswlt/NewQuickAction
There are multiple strategies that can solve this problem, but each solution has to deal with the placement of the triangle/pointer at the top of the dialog since it has to be positioned to indicate the user's selection.
I think the easiest way to solve this problem is:
Start an activity that has a transparent theme. So, apply something like android:theme="#android:style/Theme.Translucent.NoTitleBar" to the Activity in the manifest. If you want a Title Bar, do some searching for the right android-style.
Pass an extra to the activity that represents the navigation element chosen by the user. this will be used by the activity to position the triangle pointer.
Handle this extra in the activity's onCreate() method by drawing the triangle/pointer in code. This means you will want to call setContentView(...) in onCreate(), then get a reference to the ViewGroup (i.e. RelativeLayout, AbsoluteLayout, etc.). Once you have that you can call ViewGroup#addView(View child, int index) to add the ImageView that represents the triangle. You probably want to use index = 0.
Ensure that whatever View(s) you add programatically is/are not covered (i.e. hidden) by elements in the XML.
Adding the triangle is relatively easy, but positioning can get tricky. First of all, the screenshot you posted assumes a fixed-width device, and that's just not true for an Android app in the market that needs to work on 1000s of screen sizes. The Y-coordinate of the triangle/pointer is not a problem, since the height of the top-nav is probably hardcoded. It's the X-coordinate that can get tricky. What if the top-nav elements stretch? Let's assume we have a robust/decent way to get the X-position where the center of the triangle/pointer should be. Given that, I'd try using a vertical LinearLayout in my Activity and use an ImageView with a left-margin for the triangle/pointer. That's just a guess and you'll probably have to tinker with this to get the right View elements and positioning strategy for your specific implementation.

Categories

Resources