您的位置:首页 > 移动开发 > Android开发

android 抽屉效果,内容GridView来实现单行滑动

2011-10-18 22:02 633 查看
实现如下图效果:

其中抽屉xml为:

注意这个一定要设置的比你屏幕长 要不就会就不是单行显示了

android:layout_width="1100dp"

<SlidingDrawer android:id="@+id/slidingdrawer"
android:layout_alignParentBottom="true" android:layout_width="wrap_content"
android:layout_below="@id/widget31" android:layout_height="180px"
android:orientation="horizontal" android:handle="@+id/handle"
android:content="@+id/content">
<ImageButton android:id="@+id/handle"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/drag" />
<HorizontalScrollView android:id="@+id/content"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="none" android:layout_marginTop="10dip">
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="1100dp"
android:layout_gravity="center_vertical" android:layout_height="fill_parent"
android:orientation="horizontal" android:layout_marginTop="5dip">
<GridView android:id="@+id/mDiviceListContainer"
android:layout_width="fill_parent" android:layout_gravity="center_vertical"
android:layout_height="wrap_content" android:horizontalSpacing="10.0px"
android:verticalSpacing="1.0px" android:stretchMode="none"
android:numColumns="auto_fit" android:columnWidth="150px">
</GridView>
</LinearLayout>
</FrameLayout>
</HorizontalScrollView>

</SlidingDrawer>


GridView 中adapter的xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="@+id/childlayout" android:orientation="horizontal">
<RelativeLayout android:layout_width="wrap_content"
android:id="@+id/backgroundImage" android:background="@drawable/tv"
android:gravity="center" android:layout_height="wrap_content">
<TextView android:id="@+id/devicename" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐