如何将relativeLayout转换为在其他布局之上翻译和填充活动?

时间:2011-09-08 12:17:41

标签: android android-layout android-linearlayout relativelayout android-framelayout

我有一个相对布局与android:id =“@ + id / RelativeLayout02”和android:layout_alignParentBottom =“true”。

我希望用户将此布局向上拖动以使其填满屏幕并浮动在其他布局之上。

请注意我想设置拖动操作的动画。例如,如果用户将相对布局拖动到屏幕中间,则只有一半的屏幕必须填充relativeLayout。

这是我的xml布局

<?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:orientation="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>

提前感谢您的指导。

1 个答案:

答案 0 :(得分:1)

我找到了解决自己问题的方法。

解决方案是使用SlidingDrawer

可以找到教程here