Thank you.  That worked

On Jan 18, 12:03 pm, Romain Guy <[email protected]> wrote:
> Hi,
>
> You have to use the LayoutParams that correspond the your Button's
> parent. In this case, you need to use LinearLayout.LayoutParams.
>
>
>
> On Sun, Jan 18, 2009 at 7:00 AM, A R <[email protected]> wrote:
>
> > What exception are you getting? Are you running this code withing a
> > handler thread?
>
> > On Jan 17, 10:12 pm, Mark Nuetzmann <[email protected]> wrote:
> >> ok, this should be super simple but it is proving difficult.
>
> >> In my original layout xml I have 2 buttons that I want to take up
> >> equal space in a LinearLayout
>
> >>                 <LinearLayout
> >>                         android:orientation="horizontal"
> >> android:layout_width="fill_parent"
> >>                        android:layout_height="wrap_content"
> >>                        android:paddingLeft="10px" 
> >> android:paddingRight="10px" >
>
> >>                     <LinearLayout
> >>                         android:id="@+id/story_video_layout"
> >>                         android:orientation="horizontal"
> >>                         android:layout_width="fill_parent"
> >>                         android:layout_height="wrap_content"
> >>                         android:layout_weight="1">
>
> >>                             <Button
> >>                                 android:id="@+id/story_video"
> >>                                     android:layout_width="fill_parent"
> >>                                     android:layout_height="wrap_content"
> >>                                     android:text="Play Video"
> >>                                 />
> >>                     </LinearLayout>
>
> >>                     <LinearLayout
> >>                         android:orientation="horizontal"
> >>                         android:layout_width="fill_parent"
> >>                         android:layout_height="wrap_content"
> >>                         android:layout_weight="1">
>
> >>                             <Button
> >>                                 android:id="@+id/story_share"
> >>                                     android:layout_width="fill_parent"
> >>                                     android:layout_height="wrap_content"
> >>                                     android:text="Share This Story"/>
> >>                     </LinearLayout>
> >>                 </LinearLayout>
>
> >> This works fine...
>
> >> Now at runtime in the activity there are cases where I want to hide
> >> the first button (share_video) and have the other button centered and
> >> its width set to wrap_content.
>
> >> I can hide the first button just fine by using the following code,
>
> >>                 View videoLayout = findViewById(R.id.story_video_layout);
> >>                 videoLayout.setVisibility(View.GONE);
>
> >> cool...
>
> >> But no matter what I do, I cannot get the second button to center.
> >> When I make the following call just to change the layout of the button
> >> to wrap content I get exceptions being thrown and it crashes.
>
> >>                 View storyBtn = findViewById(R.id.story_share);
> >>                 LayoutParams params = new LayoutParams
> >> (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
> >>                 storyBtn.setLayoutParams(params);
>
> >> 1.  why is it crashing?
> >> 2.  what is the correct way to get the button to center in the layout
> >> correctly?
>
> >> Thank you so much for your help...
>
> --
> 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
--~--~---------~--~----~------------~-------~--~----~
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