如何在android中添加Panel?

时间:2011-03-10 09:34:21

标签: android panel

我想在android活动中添加一个面板。我会尝试解释它的行为。

它应该在我的活动的右侧显示小箭头,如果我点击那个按钮很少的面板应该滑出消耗大约20%-30%的当前活动。

屏幕上会出现类似菜单的内容。

提前致谢。

2 个答案:

答案 0 :(得分:7)

请参阅SlidingDrawer小部件。但是,此小部件仅在较旧的SDK版本上上下滑动。

否则,您应该考虑使用片段(必要时使用兼容性API)。您可以查找有关如何构建GMail应用程序的一些解释,或者查看HoneyComb库示例以获取有关动画片段的信息。

答案 1 :(得分:0)

这是我的Panel

示例
 <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/border">
        <TextView
            android:text="@string/panel_title"
            android:id="@+id/groupTitle"
            android:paddingLeft="5dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/blue" />

Here you add panel content...

</LinearLayout>

您还需要添加可绘制资源broder.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <stroke
       android:width="3dip"
       android:color="#d3d3d3" />
</shape>

值/ Colors.xml中的颜色

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <item name="blue" type="color">#FF33B5E5</item>
</resources>

面板中的标题值/ Strings.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>
  <string name="panel_title">Panel 1</string>
</resources>

可以分开添加的按钮和动画。