开发者

How to fling a relativeLayout to translate and fill the activity on top of other layouts?

I have a relative layout with android:id="@+id/RelativeLayout02" and android:layout_alignParentBottom="true".

I would like the user to drag up this layout to make it fill the screen and float on top of other layouts.

Please note that I would like to animate the drag operation. For example, if the user dragged the relative layout to the middle of the screen only half of the screen must be filled with the relativeLayout.

Here is my xml layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:or开发者_如何学编程ientation="vertical">
<LinearLayout android:id="@+id/LinearLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20px"
android:orientation="vertical"
android:gravity="center_horizontal"
>
<ImageView android:id="@+id/ImageView01"
  android:layout_width="200dip" 
  android:layout_height="81dip" 
  android:src="@drawable/logo"
android:adjustViewBounds="true"
android:layout_marginTop="15px"/>
<TextView android:id="@+id/TextView01"
  android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#FF9600""/>
</LinearLayout>
<eg.com.innova.smarthome.custom.CustomLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:gravity="center_horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_below="@id/LinearLayout01">
<ImageButton android:id="@+id/sensors" 
    android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
   android:background="@drawable/sensors"
   android:onClick="sensorImageClick"/>
<ImageButton android:id="@+id/camera_outdoor"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:background="@drawable/camera_outdoor"
android:onClick="cameraImageClick"/>
<ImageButton android:id="@+id/statistics"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:background="@drawable/statistics"/>
<ImageButton android:id="@+id/configuration2"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:background="@drawable/configuration2"
android:layout_margin="10px"/>
</eg.com.innova.smarthome.custom.CustomLayout>
<RelativeLayout android:id="@+id/RelativeLayout02"
 xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="#9CC721"
android:gravity="center_horizontal|center_vertical">
</RelativeLayout>
</RelativeLayout>

Thanks in advance for your guidance.


I have found the solution to my own question.

The soultion is to use a SlidingDrawer.

A tutorial can be found here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜