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

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

2011-08-29 17:51 281 查看
http://blog.csdn.net/sereneWorkshop/article/details/5250795

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns: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">
<LinearLayout
xmlns: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">
<TextView
android: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">
<ImageButton
android: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"
>

<RelativeLayout
android: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"
>

<RelativeLayout
android:id="@+id/left_layout"

android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="10dp"
>

</RelativeLayout>

</ScrollView>


哈哈,今天的任务完成
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: