文章目录
思路
- HorizontalScrollView在上边,其中嵌套TextView
- ViewPager在下边,其中可以嵌套ListView等组件
布局情况
说明:HorizontalScrollView只能有一个child,且是Linearlayout
铺代码
主页面布局
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="pdsu.xzl.news.MyActivity" >
<include android:id="@+id/include_top"
layout="@layout/main_top"/>
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_below="@id/include_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
</RelativeLayout>
main_top.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/bgb_bottom">
<HorizontalScrollView
android:id="@+id/hsv"
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<LinearLayout
android:id="@+id/ll_hor"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>