Hi Sagar,

It is my understanding that the constructor that takes the attribute
set is not meant for us to use directly. The system uses it when it
inflates your view. In any case, we do not need it to solve your
problem.

What we do need is to provide your view with the appropriate layout
parameters. If your view is contained in a relative layout then the
layout parameters to use would be an instance of
RelativeLayout.LayoutParams. Take a look at this class. It has an
addRule() method that should allow you to specify the same layout
rules as you do in the XML. Something along the lines of:

setRule(RelativeLayout.ALIGN_PARENT_BOTTOM, <id of the view with which
to align>);

Hope that helps,

Greg

On Feb 17, 10:06 pm, "sagar.indianic" <[email protected]>
wrote:
> Hi greg..Thanks for the reply.. Its working fine...
> But I also have another doubt..
> I m using a relative layout and I want to set alignParentBottom to
> true..
> We have a constructor like -- RelativeLayout.LayoutParams(Context c,
> AttributeSet attrs) --...
> Can u please tell me how to use attribute set?? or ne other method for
> setting align parentbottom to true?
>
> On Feb 17, 1:04 pm, Greg Krimer <[email protected]> wrote:
>
> > See the section on Layout Params 
> > here:http://developer.android.com/guide/topics/ui/declaring-layout.html
>
> > I think you need to call setLayoutParams() on your image view and pass
> > in an instance of the layout params that corresponds to the view group
> > containing your image view. For example, if your image view is
> > contained in a LinearLayout you would use LinearLayout.LayoutParams.
> > Presumably the layout params you will use extend
> > ViewGroup.MarginLayoutParams, allowing you to set the margins via the
> > setMargins() method.
>
> > On Feb 16, 10:59 pm, "sagar.indianic" <[email protected]>
> > wrote:
>
> > > Hello guys..This is urgent..can u plz help..
>
> > > On Feb 16, 2:35 pm, Sagar Parmar <[email protected]> wrote:
>
> > > > Hello every1,
>
> > > > I want to set margin for an imageview through code. i coudnt find any 
> > > > method
> > > > for that .. XML attribute is android:layout_marginLeft..what is the java
> > > > method ?? setPadding() does not work in my case.
> > > > Please help its urgent..
>
> > > > Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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