Then set it in getView().  It's a typical pattern to fiddle with views in
getView() to have the exact layout appropriate for the data being displayed
-- that's kind-of a main point of getView().

On Tue, Sep 1, 2009 at 9:30 AM, greg <[email protected]> wrote:

>
> The required indentation is variable, not known until the row data is
> retrieved during the ListAdapter's getView().  I'm not looking for a
> way to re-layout the view (which setPadding() apparently does), just a
> simple way to indent text within a TextView.  I think the approach of
> pre-padding the text with spaces will work ... although I'm curious
> about how my hierarchy line drawing in the indentation will be
> affected by marquee scrolling text.
>
>
> On Sep 1, 11:33 am, Romain Guy <[email protected]> wrote:
> > You can call setPadding(), but just don't call it from onDraw(). Why
> > do you want to call it from onDraw()? It has to be called only once.
> >
> >
> >
> > On Tue, Sep 1, 2009 at 7:40 AM, greg<[email protected]> wrote:
> >
> > > Wise Guy. :*)
> >
> > > If there is no easy method to add left indentation without causing an
> > > onDraw() loop, I'll pre-pad the char buffer with spaces and use setText
> > > (char[] text, int start, int len) to select the correct amount of left
> > > spacing.  I thought I might be overlooking a simpler approach.
> >
> > > By the way, in spite of my initial ignorance of Java and Eclipse and
> > > Android, developing an Android application has been a pleasure.  (Now,
> > > I'm only partially ignorant ... which I suppose is the best anyone can
> > > hope for in any situation. :*)  Writing system software for new
> > > hardware displaying a new UI employed by new developers is a rather
> > > bold venture.  Congratulations on pulling it off so well.
> >
> > > Best regards,
> > > Greg Sepesi
> >
> > > On Sep 1, 2:17 am, Romain Guy <[email protected]> wrote:
> > >> Don't set the padding in onDraw() :)
> >
> > >> On Mon, Aug 31, 2009 at 10:32 PM, greg<[email protected]> wrote:
> >
> > >> > My application uses a ListView to display a custom TextView as a
> tree
> > >> > view, with the text indented according to the item's depth in the
> > >> > tree.  In that indentation, a line drawing denotes the hierarchy.  I
> > >> > tried to use the setPadding() within onDraw() to indent the text,
> but
> > >> > that is causing a seemingly endless onDraw() loop ... perhaps due to
> > >> > layout recalculations.  Is there another easy method of adding left
> > >> > indentation to text that doesn't cause this drawing loop problem?
> >
> > >> > My onDraw() and row layout XML are as follows:
> >
> > >> > @Override
> > >> > protected void onDraw(Canvas canvas) {
> >
> > >> >   // some canvas.drawPath() drawn lines denoting tree hierarchy
> >
> > >> >   // unsuccessful attempt at indenting text according to mLineDepth
> > >> > (set in ListAdapter)
> > >> >   setPadding(mLineDepth * PIXELS_PER_DEPTH_LAYER +
> > >> > PIXELS_OFFSET_TO_NAME,0,0,0);
> >
> > >> >   super.onDraw(canvas);
> > >> > }
> >
> > >> > - - -
> >
> > >> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > >> > android"
> > >> >    android:orientation="horizontal"
> > >> >    android:layout_width="fill_parent"
> > >> >    android:layout_height="fill_parent">
> >
> > >> >    <view
> > >> >        class="com.mycom.myapp.TClass$MyUnderlinedTextView"
> > >> >        android:id="@+id/tlist_utext"
> > >> >            android:layout_weight="1"
> > >> >            android:layout_width="0dip"
> > >> >            android:layout_height="fill_parent"
> > >> >            android:textSize="22dip"
> > >> >        android:singleLine="true"
> > >> >        android:ellipsize="marquee"
> > >> >            android:background="@android:color/transparent" />
> >
> > >> >    <ImageView android:id="@+id/icon"
> > >> >        android:layout_width="48dip"
> > >> >        android:layout_height="48dip" />
> >
> > >> > </LinearLayout>
> >
> > >> > - - -
> >
> > >> > Best regards,
> > >> > Greg
> >
> > >> --
> > >> Romain Guy
> > >> Android framework engineer
> > >> [email protected]
> >
> > >> Note: please don't send private questions to me, as I don't have time
> > >> to provide private support.  All such questions should be posted on
> > >> public forums, where I and others can see and answer them
> >
> > --
> > Romain Guy
> > Android framework engineer
> > [email protected]
> >
> > Note: please don't send private questions to me, as I don't have time
> > to provide private support.  All such questions should be posted on
> > public forums, where I and others can see and answer them
> >
>


-- 
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.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to