[置顶] android 抽屉效果,内容GridView来实现单行滑动
16lz
2021-12-09
实现如下图效果:
其中抽屉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>
更多相关文章
- Android中设置屏幕全屏两种方法:
- android launcher2开发之 有抽屉改成无抽屉
- Android屏幕分辨率正确获取及PX,DPI,DP,SP等的对应关系
- Android系统配置数据库注释(settings.db)
- android 分辨率及密度详细
- Android屏幕常亮
- Android(安卓)屏幕设置
- android调用setRequestedOrientation之后
- android支持多行的radiogroup