【问题标题】:How to fling a relativeLayout to translate and fill the activity on top of other layouts?如何抛出 relativeLayout 以在其他布局之上翻译和填充活动?
【发布时间】:2011-09-08 12:17:40
【问题描述】:

我有一个 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>

提前感谢您的指导。

【问题讨论】:

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


    【解决方案1】:

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

    建议使用SlidingDrawer

    可以在here找到教程。

    【讨论】:

      猜你喜欢
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多