android给ScrollView中显示多个控件 --公司项目 在左边栏 加入滚条

来源:互联网 发布:网络热门歌曲 编辑:程序博客网 时间:2024/05/16 15:58

 http://blog.csdn.net/sereneWorkshop/article/details/5250795

 

<?xml version="1.0" encoding="UTF-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_height="wrap_content"    android:layout_gravity="center"     android:layout_width="fill_parent"    android:scrollbars="vertical"    android:background="#FF000000">    <ScrollView    xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="#FFc0c0c0"    android:padding="10dip"><TextViewandroid:id="@+id/about_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/about_text"android:textColor="#FF000000"android:autoLink="all"android:textSize="20sp"/><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"  android:layout_height="wrap_content" android:gravity="center"><ImageButtonandroid:layout_gravity="center" android:id="@+id/about_exit"android:src="@drawable/looks"android:background="#FF46333c"android:scaleType="center"android:layout_width="wrap_content"android:layout_height="fill_parent"android:text="@string/about_ok"/><TextView android:id="@+id/about_text_exit"android:layout_height="fill_parent"android:layout_width="wrap_content"android:background="#FF46333c"android:text="Let's Go!"android:layout_toRightOf="@id/about_exit"android:layout_alignTop="@id/about_exit"android:layout_alignBottom="@id/about_exit"android:clickable="true"/></RelativeLayout></LinearLayout></ScrollView></LinearLayout>

 

 

在左边栏 ,加入 侧边 栏 滚条

<!-- 左边 块 --><!-- Alex --><ScrollView android:layout_height="wrap_content"android:id="@+id/Left_layout_ScrollV"android:layout_width="wrap_content"android:layout_below="@+id/top"android:layout_above="@+id/bottom"><RelativeLayoutandroid:id="@+id/left_layout"android:background="@+drawable/filter_back"android:visibility="gone"android:layout_width="wrap_content"android:layout_height="fill_parent"></RelativeLayout></ScrollView>


 

 

 

 

--------------------------------------------------------------------------------以上是测试案例,一下是 项目中 解决自己问题的做法

 

将 ScrollView套在 left_layout 外面, 将 左边的 的布局 RelativLayout 的 想对布局 改为 ScrollView

因为  left_layout 中 有 backGround 所以 使得 滚条过长,所以再将 backgroud 去掉

 

<!-- 左边 块 --><!-- Alex  将背景图 去掉 就解决过长的问题 了 android:background="@+drawable/filter_back"--><ScrollView android:id="@+id/Left_layout_ScrollV"android:layout_height="wrap_content"  android:layout_width="wrap_content"android:layout_below="@+id/top"android:layout_above="@+id/bottom"android:fillViewport="true" ><RelativeLayoutandroid:id="@+id/left_layout"android:visibility="gone"android:layout_width="wrap_content"android:layout_height="10dp"></RelativeLayout></ScrollView>


哈哈,今天的任务完成

原创粉丝点击