Reputation: 950
I am have an activity in android application . It displays a view (lets say CurrentView)with a button in the centre of the screen . I am setting the content of the activity using : setContentView(R.layout.layout_xml_file); The layout xml file defines the button.
My requirement is that , when user clicks on the button , i need to show another view (lets say NewView)containing a listView on Current View. The NewView transition should happen like this : It should start from bottom of the screen and should take some proportion of the screen , say 3/4 or 1/2 . I mean the view's height should be configurable . This NewView should be in the same activity . I do not want to create another activity for displaying it. I don't understand which android widget is should use for holding the NewView
Thanks. Your help is appreciated ...
Upvotes: 1
Views: 4497
Reputation: 527
Take a Relative Layout align to bottom and set its height what you want and inside Relative Layout Take Listview after that setVisibility gone. And when click button in activity setVisibility Visible.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="128dp"
android:id="@+id/button" />
<RelativeLayout
android:id="@+id/rel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#f0f0f0"
android:layout_below="@+id/button"
android:visibility="gone">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:divider="#000"
android:dividerHeight="1dp"/>
</RelativeLayout>
</RelativeLayout>
Upvotes: 3
Reputation: 3190
I think you are looking something like this library -> https://github.com/umano/AndroidSlidingUpPanel
Upvotes: 0
Reputation: 226
Upvotes: 2
Reputation: 1825
perhaps use FrameLayout for both views parent layout. Initially the list should be inivisble and button visible.
Upvotes: 0