set the layout weight of TextView to 1.
<TextView android:id="@+id/atitle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight= "1"
/>
</LinearLayout>
On Jan 5, 2:13 pm, Beth <[email protected]> wrote:
> The problem may be that the TextView atitle has
> android:layout_width="fill_parent". Try setting it to wrap_content
> and see if you get better results.
>
> Regards,
> Beth
>
> On Jan 5, 1:57 pm, n179911 <[email protected]> wrote:
>
>
>
> > Hi,
>
> > I have a linear layout like this:
>
> > <LinearLayout android:id="@+id/header"
> > android:layout_width="fill_parent"
> > android:layout_height="wrap_content"
> > android:orientation="horizontal"
> > android:gravity="center_vertical"
> > <ImageView android:id="@+id/icon"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:layout_gravity="top"
> > android:src="@drawable/img1" />
> > <TextView android:id="@+id/atitle"
> > android:singleLine="true"
> > android:layout_width="fill_parent"
> > android:layout_height="wrap_content" />
> > </LinearLayout>
>
> > And I need to add a button to the above layout programatically which
> > is right justified? I need to do that in code instead of layout xml
> > file (this is because i can't modify that layout xml file)
>
> > Here is what I am doing:
> > LinearLayout header = (LinearLayout) findViewById(R.id.header);
> > Button buyButton = new Button(this);
> > buyButton.setText(R.string.buy_ringtone);
> > buyButton.setLayoutParams(new LayoutParams(
> > ViewGroup.LayoutParams.WRAP_CONTENT,
> > ViewGroup.LayoutParams.WRAP_CONTENT));
> > header.addView(buyButton);
>
> > But the button does not appear. Can you please tell me how can i achieve
> > that?- 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