Ok I have a relative layout inside a linear one.Until now,the relative layout was perfect,however now a big problem appeared.
A relative layout is based on the others item’s position.For ex button2 is at the bottom of button1,and so on…and if button 1 disappears,button2 gets…”nuts”.
That’s my problem, when a button disappears one of the 4 buttons gets…up.
What I need is to position the buttons like this:
Button1 and button 2 at the middle of the screen,and 3 and 4 lower,but not really at the bottom.
I tried to modify it in relative layout but I failed…Hope you can help me.
Here’s the code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView2"
android:text="TextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</TextView>
<Button
android:textSize="20dp"
android:layout_height="wrap_content"
android:id="@+id/button3"
android:text="Button"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="27dp"
android:layout_alignParentBottom="true">
</Button>
<TextView
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:text="TextView"
android:layout_above="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="74dp">
</TextView>
<Button
android:textSize="20dp"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="Button"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true">
</Button>
<Button
android:textSize="20dp"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:paddingRight="30dp"
android:paddingBottom="90px"
android:text="Button"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/button3">
</Button>
<Button
android:textSize="20dp"
android:layout_height="wrap_content"
android:gravity="bottom"
android:id="@+id/button4"
android:text="Button"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/button3"
android:layout_alignBottom="@+id/button3"
android:layout_alignParentRight="true">
</Button>
</RelativeLayout>
Here’s the code I use to make the button invisible:
Button b1 = (Button) findViewById(R.id.button1);
Button b2 = (Button) findViewById(R.id.button2);
Button b3 = (Button) findViewById(R.id.button3);
Button b4 = (Button) findViewById(R.id.button4);
b1.setVisibility(View.GONE);
if you are using
view.setVisibility(View.GONE)..then tryView.INVISIBLEhere view = (your textview,button anything)