[android-developers] Re: How can I add a button to a linear layout 'right justified'
http://www.androidpeople.com/category/button/ use button gravity property. ex:- Private Button b1; b1.setGravity(Gravity.RIGHT); On Jan 6, 1:16 am, n179911 wrote: > On Tue, Jan 5, 2010 at 11:30 AM, Iroid wrote: > > set the layout weight of TextView to 1. > > > android:singleLine="true" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:layout_weight= "1" > > /> > > > > I have tried this. But when I view the button in HierachyViewer, the > height is 48, but the width is 0? > > Any more idea? > > Thank you. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How can I add a button to a linear layout 'right justified'
On Tue, Jan 5, 2010 at 11:30 AM, Iroid wrote: > set the layout weight of TextView to 1. > android:singleLine="true" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:layout_weight= "1" > /> > > > I have tried this. But when I view the button in HierachyViewer, the height is 48, but the width is 0? Any more idea? Thank you. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How can I add a button to a linear layout 'right justified'
set the layout weight of TextView to 1. On Jan 5, 2:13 pm, Beth 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 wrote: > > > > > Hi, > > > I have a linear layout like this: > > > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:orientation="horizontal" > > android:gravity="center_vertical" > > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:layout_gravity="top" > > android:src="@drawable/img1" /> > > > android:singleLine="true" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" /> > > > > > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How can I add a button to a linear layout 'right justified'
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 wrote: > Hi, > > I have a linear layout like this: > > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:orientation="horizontal" > android:gravity="center_vertical" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:layout_gravity="top" > android:src="@drawable/img1" /> > android:singleLine="true" > android:layout_width="fill_parent" > android:layout_height="wrap_content" /> > > > 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? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en