i want to have two relativelayout in first relativelayout have map and in second relativelayout i have the list..,i want on starting only layout with map will be visible on screen with a button,,when i click on button then layout with listview get open from right side with new new button on the top of it,,and prevoius button get hide.and screen get divided with two parts with different layouts..i have done some thing but from starting onward m getting half half screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ListView_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1" >
<RelativeLayout
android:id="@+id/rl_ListView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/getdirection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Directions" />
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" >
</fragment>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_ListView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:visibility="invisible" >
<Button
android:id="@+id/hide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Directions" />
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
MainActivity
show = (TextView)findViewById(R.id.getdirection);
show1 = (TextView)findViewById(R.id.hide);
rt = (RelativeLayout)findViewById(R.id.rl_ListView2);
show.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(rt.getVisibility()==View.INVISIBLE)
{
rt.setVisibility(View.VISIBLE);
}
show.setVisibility(View.INVISIBLE);
}
});
show1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(rt.getVisibility()==View.VISIBLE)
{
rt.setVisibility(View.INVISIBLE);
}
show1.setVisibility(View.INVISIBLE);
}
});
You can try with
isShown()
as suggested by AmiyaSet visibility as Gone instead of Invisible
Try this:
You are getting layout1 in half screen from starting due to weight property. You can try not giving weight in starting and give it programatically on button click.
Hope this helps.