any ideas on this?

i'd be able to get round it if i could treat views in the layout XML 
as templates and instantiate new ones, but i get the same one back 
each time.

but setPadding() or setMargins() *should* work. the actual code in 
the inflater isn't that different, but it flat-out won't work here 
for some reason.

any help appreciated.
j




>What is top_view?
>
>On Thu, Sep 3, 2009 at 2:12 PM, Jason
>Proctor<[email protected]> wrote:
>>
>>  sorry - i thought that mentioning i'd tried setPadding() and
>>  MarginLayoutParams was enough to give an idea of what the code looked
>>  like.
>>
>>  // assuming
>>  ViewGroup group = (ViewGroup) findViewById (R.id.top_view);
>>
>>  // try 1
>>  WebView web = new WebView (this);
>>  webView.setPadding (30, 10, 30, 10);
>>  group.addView (web);
>>
>>  // try 2
>>  WebView web = new WebView (this);
>>  ViewGroup.MarginLayoutParams params = new
>>  ViewGroup.MarginLayoutParams (ViewGroup.FILL_PARENT,
>>  ViewGroup.WRAP_CONTENT);
>>  params.setMargins (30, 10, 30, 10);
>>  group.addView (web, params);
>>
>>  in both cases the WebView fills the parent's width, despite the
>>  padding set up in the first snippet or the margins set up in the
>>  second snippet.
>>
>>  however, if i declare the webview in the layout file, as such --
>>
>>
>>  <WebView
>>         android:id="@+id/web_view"
>>         android:layout_width="fill_parent"
>>         android:layout_height="wrap_content"
>>         android:layout_marginLeft="30px"
>>         android:layout_marginRight="30px"
>>         android:layout_marginTop="10px"
>>         android:layout_marginBottom="10px"
>>  />
>>
>>  then the webview insets appropriately.
>>
>>  any help appreciated!
>>
>>  thanks,
>>  j
>>
>>
>>
>>>Without seeing your code...
>>>
>>>On Thu, Sep 3, 2009 at 12:00 PM, Jason
>>>Proctor<[email protected]> wrote:
>>>>
>>>>   anyone? this is a fairly simple thing to want to do, and the
>>>>   documented ways of doing it don't work. do i log a bug?
>>>>
>>>>
>>>>
>>>>>hey -- i'm programmatically adding views to a LinearLayout inside a
>>>>>ScrollView and i'm running into some issues setting margins and
>>>>>padding etc for child views of the LinearLayout.
>>>>>
>>>>>i've tried child.setPadding() and adding the view with a
>>>>>MarginLayoutParams set up right, but the child view still fills the
>>>>>parent width.
>>>>>
>>>>>what is the correct way to programmatically set the parameters which
>>>>>are set statically by layout_marginLeft, layout_marginRight, etc?
>>>>
>>>>
>>>>   --
>>>>   jason.vp.engineering.particle
>>>>
>>>>   >
>>>>
>>>
>>>
>>>
>>>--
>>>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
>>>
>>>
>>
>>  --
>>  jason.vp.engineering.particle
>>
>>  >
>>
>
>
>
>--
>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
>
>

-- 
jason.vp.engineering.particle

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