Taking a step back here. I think if I solve the Dialog itself, the
Window background drawable may not be an issue. Saying that because
once I created the 9-patch with correct transparency and Content and
Patch settings, it looks as it should.
So, trying to get the dialog layout (view) right first.
Code:
// 1 - specify the layout (pretty simple stuff)
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://
schemas.android.com/apk/res/android"
android:id="@+id/layout_root0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff80000" <!-- gives me a red bar
at the top of the dialog -->
>
<ListView
android:id="@+id/shareList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tenth" <!-- my 9-patch.
Correctly
displays as expected -->
>
</ListView>
</LinearLayout>
// 2 - inflate and populate the View
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.bc, null);
ListView shareList =
(ListView)textEntryView.findViewById(R.id.shareList);
shareList.setAdapter(gla);
// 3. Now, display the dialog (turn off the title
bar)
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true)
.setView(textEntryView);
mAlert = builder.create();
mAlert.requestWindowFeature(Window.FEATURE_NO_TITLE);
mAlert.show();
This code will produce a nice alert dialog with a perfect 9-patch
surrounding the ListView (options items) and a red bar at the top of
the ListView.
**Problem** -- Still have a "border" around the LinearLayout. There is
a thin black horizontal bar at the top *and* a 1-pixel frame around
the whole thing. Its that "frame" around the dialog I want to get rid
of.
Is that a remnant of the LinearLayout that wraps the ListView? Do I
need to specify some sort of "no border" attribute to the
LinearLayout? Or is it a remnant of the Dialog? Do I need to do
something beyond the requestWindowFeature (no title) statement?
On Apr 2, 7:36 pm, Dianne Hackborn <[email protected]> wrote:
> The window will be resized to wrap its content. Be sure in your 9-patch
> that you have correctly indicated the content area along the right and
> bottom edges. If that isn't the problem, you can use hierarchyviewer to see
> what is going on with the layout of the view hierarchy if your window. You
> don't want to set a specific layout size.
>
> On Sat, Apr 2, 2011 at 4:30 PM, Nick Longinow <[email protected]>wrote:
>
>
>
>
>
> > Getting much closer. But not quite. I've got my customized background
> > (nine patch) built and assigned to the alert window. But, its huge
> > while the dialog list items are normal size. I did
> > alert.getWindow().setLayout(50, 50) to resize that window but it has
> > no effect. Still have this huge background and small dialog
> > contents. Must be missing something big here.
>
> > Here is my Dialog display code:
>
> > mAlert = builder.create();
> > mAlert.requestWindowFeature(Window.FEATURE_NO_TITLE);
> > mAlert.getWindow().setLayout(50, 50);
> > // *** this is the nine patch (looks
> > beautiful by the way, just huge)
>
> > mAlert.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.eight));
> > // ***
> > mAlert.show();
>
> > On Apr 2, 4:16 pm, Nick Longinow <[email protected]> wrote:
> > > Successfully got a .9.png file created and applied it to my ListView -
> > > looks very nice. Problem - the AlertDialog I want to use it for seems
> > > to add a rectangle with white interior as a container or border around
> > > my ListView. I'd like it to be transparent, and only show the
> > > ListView. Do I have to do an "extends alertdialog" class to get rid of
> > > that white border?
>
> > > On Mar 30, 6:21 pm, Nick Longinow <[email protected]> wrote:
>
> > > > Then that's what I'll do. Moving the triangle around randomly isn't
> > > > very important. Thanks all.
>
> > > > On Mar 29, 10:29 pm, Dianne Hackborn <[email protected]> wrote:
>
> > > > > No, use a 9-patch. That said, if you want to actually position the
> > triangle
> > > > > at different places in the border you probably will need to give up
> > on just
> > > > > setting a custom background drawable and have to draw your own
> > background
> > > > > with things positioned where you want.
>
> > > > > On Tue, Mar 29, 2011 at 6:06 PM, Nick Longinow <
> > [email protected]>wrote:
>
> > > > > > I'm looking for something more like a <shape> where the vertices
> > are
> > > > > > set to like a rectangle, but with one side that has a triangle
> > shape
> > > > > > coming out of it. I believe I create this as a drawable in the XML
> > > > > > layout, and then set the Dialog to use this drawable as the
> > > > > > background. True so far?
>
> > > > > > On Mar 27, 11:01 pm, Hari Edo <[email protected]> wrote:
> > > > > > > If you mean like the SMS app, you can do that with a .9.png
> > > > > > > image file, also called a "Nine Patch."
>
> >http://developer.android.com/guide/topics/graphics/2d-graphics.html#n...
>
> > > > > > > On Mar 27, 10:34 pm, Nick Longinow <[email protected]>
> > wrote:
>
> > > > > > > > Like a balloon-style dialog, with one side of the dialog having
> > a
> > > > > > > > triangle coming out of it so that the dialog appears to point
> > to some
> > > > > > > > portion of the screen. I've seen these in alot of apps - what
> > is the
> > > > > > > > basic idea here? Is it use of shapes and themes? Any simple
> > examples
> > > > > > > > out there?- Hide quoted text -
>
> > > > > > > - Show quoted text -
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > [email protected]
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > > --
> > > > > Dianne Hackborn
> > > > > Android framework engineer
> > > > > [email protected]
>
> > > > > Note: please don't send private questions to me, as I don't have time
> > to
> > > > > provide private support, and so won't reply to such e-mails. All
> > such
> > > > > questions should be posted on public forums, where I and others can
> > see and
> > > > > answer them.- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails. All such
> questions should be posted on public forums, where I and others can see and
> answer them.- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en