When I declare 3 TextViews in RelativeLayout, 'textA', 'textB', and 'textC'. The textC should appear below textB. But when run, the textC displayed in improper position (at the top-left of screen).
I don't know can textC use android:layout_below to textB.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent" >
<TextView
android:id="#+id/textA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="This is TextA : " />
<TextView
android:id="#+id/textB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/textA"
android:layout_alignBaseline="#id/textA"
android:text="this is textB" />
<TextView
android:id="#+id/textC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/textB"
android:text="This is TextC" />
</RelativeLayout>
You can also change
android:layout_below="#id/textA"
to textC
The complete Example would look:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent" >
<TextView
android:id="#+id/textA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="This is TextA : " />
<TextView
android:id="#+id/textB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textA"
android:layout_alignBaseline="#+id/textA"
android:text="this is textB" />
<TextView
android:id="#+id/textC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textB"
android:layout_below="#+id/textA"
android:text="This is TextC" />
Just make below changes for the TextView3 :
<TextView
android:id="#+id/textC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textB"
android:layout_below="#+id/textA"
android:text="This is TextC" />
It cannot use vertical alignment to the elements that use alignBaseline to other elements. Then in this case in 'textB' change alignBaseline to be alignTop like in the code.
<TextView
android:id="#+id/textB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/textA"
android:layout_alignTop="#id/textA"
android:text="this is textB" />
Using this way it will support muti-line for textB.
Related
I have the following layout for a ListView item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_icon_image"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="#drawable/m" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Business Name"
android:id="#+id/item_title_text"
android:layout_toRightOf="#+id/item_icon_image"
android:layout_marginLeft="3dp"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignTop="#+id/item_icon_image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Distance"
android:id="#+id/item_distance_text"
android:layout_alignLeft="#+id/item_title_text"
android:layout_alignBottom="#+id/item_icon_image" />
</RelativeLayout>
And this is the rendered result:
As you can see there is a gap between the real text and the bottom of the image... I was expecting to have the bottom of the text matching exactly with the bottom of the image...so question is: How can I align the text to the bottom of the image?
(this also happens for the top text, but in the top instead)
EDIT:
For now I am using:
android:layout_marginBottom="-10dp"
But I wanted something more automatic, some solution that won't depend on dp or screen....but as commented, this might be impossible, because the View needs to make space for letter such as 'y', 'g' and 'j'....but I wish there could be something that will align it based on it's contents, so if there wasn't a 'g', it won't be saving this space.
You should add android:gravity="top" to your top text view and android:gravity="bottom" to your bottom text view to get the desired result.
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/item_icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/item_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Business Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="odp"
android:layout_weight="1"/>
<TextView
android:id="#+id/item_distance_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
Do it like this to acheive the desired result:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Distance"
android:id="#+id/item_distance_text"
android:layout_alignLeft="#+id/item_title_text"
android:layout_alignBottom="#+id/item_icon_image"
android:gravity="bottom" />
As seen in picture below I need a layout where Textview containing contents 'Hello' and layout '2' are always visible and are between layout '1' and ']'
{1}Hello{2} ]
{1}Hello I..{2}]
If textview contents are too long they should ellipsize
Layout '2' shouldn't be right aligned to parent or ']', but be next to TextView
I have tried playing with wieghts and relative layout but do not seem to get a working solution.
Any ideas/pointers?
Here is slimdown version of my layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/simple_white_button"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/topLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.85"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/photo"
android:layout_width="75dp"
android:layout_height="75dp"
android:scaleType="centerCrop"
android:src="#drawable/headshot_alt"
android:visibility="visible" />
<LinearLayout
android:id="#+id/myRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/photo" >
<TextView
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:singleLine="true"
android:text="New Jersey"
android:textColor="#color/grey_text"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/weather"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:gravity="left" >
<!-- Weather -->
<ImageView
android:id="#+id/imgWeather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_notification_news"
android:visibility="visible" />
<TextView
android:id="#+id/txtWeather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3dp"
android:gravity="center_vertical"
android:text="50/43"
android:textColor="#color/text_dark"
android:textSize="13sp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/menu"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.15"
android:background="#drawable/simple_white_button"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/menu_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="#drawable/ic_quickaction_default" />
</LinearLayout>
</LinearLayout>
Where {1} would be the id = photo, ] is id=menu and id=myRow is the textview + weather layout i want in between photo and menu. I preferably do not want to set max width on my address text view, in worst case i want it ellipsize when weather touches the menu, But when address is small i want weather next to address and not close to menu
Hopefully its bit more clear now
In a relative layout, with fixed width for the textview, Layout'2' as layout_toRightOf the textview, something like this:
<TextView
android:id="#+id/firstText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:text="Hello String"
android:lines="1"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/layoutTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/firstText"
android:background="#android:color/white"
android:text="Layout 2"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Provide the container layout as per your requirement. With a fill_parent width, you can adjust the "]" to be at the extreme right or xdp away after your Layout 2
Can you specify, precisely, what is required...i'l edit my answer
I've got some problem with positioning TextViews. Currently my layout looks like:
Text1: Text2
Text3: Text4
Ok, but when Text2 has 2 rows length or more I've got:
Text1: Text2:1
Text3: Text2:2/Text4
I don't know how to set up my layout to obtain view like:
Text1: Text2:1
Text2:2
Text3: Text4
Can somebody help me solve that problem?
XML code:
(...)
//Text1:
<TextView
android:id="#+id/tv_author_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_genre_label"
android:layout_toRightOf="#+id/img_Cover"
android:text="Author: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
//Text2:
<TextView
android:id="#+id/tv_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tv_author_label"
android:layout_alignBottom="#+id/tv_author_label"
android:layout_toRightOf="#+id/tv_author_label"
android:text="Anonymous Anonymous"
android:textAppearance="?android:attr/textAppearanceMedium" />
//Text3:
<TextView
android:id="#+id/tv_availability_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_author_label"
android:layout_toRightOf="#+id/img_Cover"
android:
android:textStyle="bold"
android:text="Availability: "
android:textAppearance="?android:attr/textAppearanceMedium" />
//Text4:
<TextView
android:id="#+id/tv_availability"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tv_availability_label"
android:layout_alignBottom="#+id/tv_availability_label"
android:layout_toRightOf="#+id/tv_availability_label"
android:layout_alignParentLeft="#+id/tv_availability_label"
android:layout_below="#+id/tv_author"
android:text="b/d"
android:textAppearance="?android:attr/textAppearanceMedium" />
(...)
you can reconstruct your code something like this,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dfsdjfkd dsfsdf sdfsdf sdfsdfsd fjlsdjf sdj; j; jlksdfjl sdjflkdsjflsdk jkldsjf lsjldkfj sdl" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id="#+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</LinearLayout>
I hope it will be helpful !!
You can encapsulate the row of text views inside a linear layout with orientation - horiontal
I'm using android:layout_below & android:layout_above on a RelativeLayout which contains (com.test.richedit.RichTextEditor) to attempt to always render it above my bottom RelativeLayout: (com.test.SetCancelButtons) & always below my LinearLayout (com.test.MenuBarTopNote) . However when I do this the com.test.richedit.RichTextEditor doesn't show up at all. I have also tried just using android:layout_below="#+id/menu_bar_top" and not specifying a android:layout_above, however, when typing many lines of text the EditText grows to the pont where is goes behind the bottom footer bar (com.test.SetCancelButtons). I essentially want the Edit Text to always be the same size stretched between the top header bar and bottom footer bar and just the content to be scrollable
The com.test.richedit.RichTextEditor is essentially a LinearLayout containing some buttons for styling the text in an EdiText below it.
I have used android:layout_below & android:layout_above together before on a ListView and it worked fine, how can I achieve the same result in this case?
The xml where I'm trying to center com.test.richedit.RichTextEditor above and below 2 views:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/llayNote"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#drawable/bkgrd_event_new">
<com.test.StatusBar
android:id="#+id/statusbar"
android:layout_width="fill_parent"
android:layout_height="49dip"
android:paddingTop="0dip"
android:background="#drawable/statusbar"
/>
<com.test.MenuBarTopNote
android:id="#+id/menu_bar_top"
android:layout_below="#+id/statusbar"
android:layout_width="fill_parent"
android:layout_height="104dip"
android:background="#drawable/menu_bar_top1"
/>
<!-- EDIT SUBJECT -->
<RelativeLayout
android:layout_below="#+id/menu_bar_top"
android:layout_above="#+id/setcancelbuttons"
android:layout_marginLeft="8dip"
android:layout_marginTop="10dip"
android:layout_marginRight="8dip"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.test.richedit.RichTextEditor
android:id="#+id/edNoteSubject"
android:layout_width="wrap_content" android:layout_height="wrap_content"
/>
</RelativeLayout>
<com.test.SetCancelButtons
android:layout_alignParentBottom="true"
android:id="#+id/setcancelbuttons"
android:layout_width="wrap_content"
android:layout_marginTop="20dip"
android:layout_height="wrap_content" />
</RelativeLayout>
The com.test.richedit.RichTextEditor:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip"
>
<LinearLayout android:id="#+id/toolbar"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dip"
>
<ToggleButton
android:id="#+id/bold"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textOn="B"
android:textOff="B"
android:textColor="#464646" />
<ToggleButton
android:id="#+id/italic"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textOn="I"
android:textOff="I"
android:textColor="#464646" />
<ToggleButton
android:id="#+id/underline"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textOn="U"
android:textOff="U"
android:textColor="#464646" />
<Button
android:id="#+id/size"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text=" SIZE "
android:textColor="#000000" />
<Button
android:id="#+id/color"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text=" COLOR "
android:textColor="#000000" />
<Button
android:id="#+id/link"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text=" LINK "
android:textColor="#464646" />
<ToggleButton
android:id="#+id/html"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textOn=" HTML "
android:textOff=" HTML "
android:textColor="#464646" />
<!--
<ToggleButton
android:id="#+id/strike"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/underline"
android:layout_toRightOf="#id/underline"
android:textSize="17dip"
android:textOn="#string/strike"
android:textOff="#string/strike"
android:textColor="#464646" />
<Button
android:id="#+id/link"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/strike"
android:layout_toRightOf="#id/strike"
android:textSize="17dip"
android:textColor="#21759b"
android:text="#string/link" />
<ToggleButton
android:id="#+id/bquote"
android:background="#drawable/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/link"
android:layout_toRightOf="#id/link"
android:textSize="17dip"
android:textOn="b-quote"
android:textOff="b-quote"
android:textColor="#464646" />
-->
</LinearLayout>
<EditText android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:gravity="top"
android:minLines="1"
android:textColorLink="#21759b" />
<!-- android:autoText="true" -->
</LinearLayout>
I'm not good in xml layout in android, but why don't you try putting "fill_parent" on both width and height of the richtexteditor and also add weight set to 1 to make sure the the object will fill all the remaining space on the view so it will look like this:
<com.test.richedit.RichTextEditor
android:id="#+id/edNoteSubject"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
hope this will help you.
Try moving the setCancelButton above the RichTextEditor view within the layout. Also set RichTextEditor layout's width and height to fill_parent
Im hiding a button from within a handler (This is after i have made it Visible in another state of the app). The handler receives a message from a running thread and then updates the GUI.
The problem is that nearby (not all) buttons and textviews are also dissappearing from the screen.. Im using Relative Layout.
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget54"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/btnFold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Fold"
android:visibility="invisible"/ >
<Button
android:id="#+id/btnRaise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/btnFold"
android:text="Raise"
android:visibility="invisible"/>
<Button
android:id="#+id/btnCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/btnRaise"
android:text="Call"
android:visibility="invisible" />
<TextView
android:id="#+id/txtFlopTurnRiver"
android:layout_width="135dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" " />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnCall"
android:layout_toLeftOf="#+id/btnCall"
android:text="Chip amount:" />
<TextView
android:id="#+id/txtHand1"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_above="#+id/textView1"
android:layout_centerHorizontal="true"
android:text=" " />
<Button
android:id="#+id/btnDeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="#string/deal_deck"
android:visibility="invisible" />
<Button
android:id="#+id/btnRiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/btnDeal"
android:text="River"
android:visibility="invisible" />
<TextView
android:id="#+id/txtHand2"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_above="#+id/txtHand1"
android:layout_toLeftOf="#+id/btnRaise"
android:text=" " />
<TextView
android:id="#+id/txtHand3"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/btnRaise"
android:layout_centerVertical="true"
android:text=" " />
<TextView
android:id="#+id/txtHand8"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_above="#+id/txtHand1"
android:layout_alignLeft="#+id/btnRiver"
android:text=" " />
<TextView
android:id="#+id/txtHand6"
android:layout_width="73dp"
android:layout_height="21dp"
android:layout_above="#+id/txtFlopTurnRiver"
android:layout_alignLeft="#+id/txtHand8"
android:layout_marginBottom="26dp"
android:text=" " />
<TextView
android:id="#+id/txtHand4"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtHand6"
android:layout_alignBottom="#+id/txtHand6"
android:layout_toLeftOf="#+id/btnRaise"
android:text=" " />
<TextView
android:id="#+id/txtHand5"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_above="#+id/txtHand4"
android:layout_alignLeft="#+id/txtHand1"
android:layout_marginBottom="14dp"
android:text=" " />
<TextView
android:id="#+id/txtHand7"
android:layout_width="73dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtHand3"
android:layout_alignBottom="#+id/txtHand3"
android:layout_alignRight="#+id/btnRiver"
android:layout_marginRight="26dp"
android:text=" " />
<TextView
android:id="#+id/txtChipAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_toLeftOf="#+id/btnCall"
android:layout_toRightOf="#+id/txtHand1"
android:text="103360" />
Does anyone know what could be causing the problem?
btnFold = (Button)findViewById(R.id.btnFold);
btnFold.setVisibility(View.GONE);
Now that I see your full xml - when you set a View to GONE, views that are set relative to it (layout_toLeftOf, layout_above) are put in the top left (or wherever their other constraints put them, e.g. a view that is toLeftOf and aligned parent bottom will go to the bottom left of screen now (it has nothing to be toLeftOf and is on bottom). I'd recommend setting View.INVISIBLE if you just want to hide a View, not View.GONE unless you have a specific reason for that?
Just wrap the button you want to hide with a
<LinearLayout
android:id="#+id/LLid"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
....
>
</LinearLayout>
And made all layout_toLeftOf to the LinearLayout(LLid)
After that you define a visibility:gone to your button, and show them with setVisibility(VIEW.VISIBLE)