ScrollView的用法,隐藏滚动条

我之前写了一个ScrollView老是报java.lang.IllegalStateException: ScrollView can host only one direct child,意思是说:ScrollView只能有一个子布局,所以用一个布局把你写的布局抱起来就OK,隐藏滚动条。

<pre name="code" class="java"><pre name="code" class="java"><ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none" >//设置隐藏滚动条

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:gravity="center"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是左边的"
                    android:textSize="25sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="我是右边的"
                    android:textSize="25sp" />
            </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@android:color/black" />
        </LinearLayout>
    </ScrollView>


效果如下:

时间: 2024-08-29 00:07:49

ScrollView的用法,隐藏滚动条的相关文章

css设置滚动条颜色与样式以及如何去掉与隐藏滚动条

我们大家在浏览网页的时偶尔会看到很漂亮的各种颜色样式的滚动条,这就是通过css代码控制来实现的,于是本人搜集整理一番,这里和大家分享一下使用CSS设置滚动条颜色以及如何去掉滚动条的方法,需要的朋友可以参考下,很有用的 1 div { 2 scrollbar-face-color: #fcfcfc; 3 scrollbar-highlight-color: #6c6c90; 4 scrollbar-shadow-color: #fcfcfc; 5 scrollbar-3dlight-color:

CSS中隐藏滚动条的简单实现方法

xhtml中隐藏滚动条 在用ie6浏览有框架的xhtml页面的时候,默认会水平和垂直滚动条会一起出现,这是ie6的一个 bug,在firefox上是正常的,出现的原因是其对XHTML 1.0 transitional doctype的解释缺陷. 对于这个bug一般有3种解决方案, 方法1: 代码: 程序代码 html { overflow-y: scroll; } 原理:强制显示ie的垂直滚动条,而忽略水平滚动条 优点:完全解决了这个问题, 允许你保持完整的XHTML doctype. 缺点:即

css隐藏滚动条方法

1.完全隐藏 在<boby>里加入scroll="no",可隐藏滚动条:<boby scroll="no"> 2.在不需要时隐藏 指当浏览器窗口宽度或高度大于页面的宽或高时,不显示滚动条:反之,则显示:<boby scroll="auto"> 3.样式表方法 在<boby>里加入style="overflow-x:hidden",可隐藏水平滚动条:加入style="ov

IWebBrowser隐藏滚动条

刚才在项目里看到一个IWebBrowser2,竟然需要通过MoveWindow的方式把滚动条遮挡,如果要缩小IWebBrowser2控件的显示大小呢?这种方法至少我用不习惯,起码也得从源头解决这样的问题吧! 所以百度之,谷歌之~ 我的项目使用的是WTL/ATL,所以用WTL/ATL的方式写了一个隐藏滚动条的实现.勿喷~~~ IWebBrowser2的定义和初始化,我就不用说了,这里直接在NavigateComplete里写的, 1 /* 2 * CComPtr<IWebBrowser2> m_

Extjs 显示或隐藏滚动条

转自: http://www.cnblogs.com/exmyth/archive/2013/04/15/3021861.html bodyStyle :'overflow-x:hidden;overflow-y:scroll', //隐藏水平滚动条,显示用overflow-x:visible hidden 隐藏   scroll :一定有  auto:自动 通过这个方法可以显示或隐藏滚动条 var form = new Ext.form.FormPanel({  frame : true,  

CSS中隐藏滚动条的方法

xhtml中隐藏滚动条 在用ie6浏览有框架的xhtml页面的时候,默认会水平和垂直滚动条会一起出现,这是ie6的一个 bug,在firefox上是正常的,出现的原因是其对XHTML 1.0 transitional doctype的解释缺陷. 对于这个bug一般有3种解决方案, 方法1: 代码: 程序代码 html { overflow-y: scroll; } 原理:强制显示ie的垂直滚动条,而忽略水平滚动条 优点:完全解决了这个问题, 允许你保持完整的XHTML doctype. 缺点:即

怎样隐藏“滚动条”?

什么是"滚动条"? 滚动条是指图右侧被红线框起来的部分: 只要网页内容大于视图,滚动条就会出现. 一般来说,只要不是 body 层次的滚动条,使用 overflow: hidden; 就能解决滚动条出现的问题,但是此时页面也会变得无法捲动. 目前网络上已经有诸多可以隐藏非 body 层次的滚动条又可捲动页面的方法,所以本文主要聚焦于如何隐藏浏览器(也就是 body 层次)的滚动条. 解决方法 针对不同的浏览器,有不同的隐藏滚动条的方法,以下针对三大浏览器 chrome.ie(包括 ed

CSS 实现隐藏滚动条同时又可以滚动

移动端页面为了更接近原生的体验,是否可以隐藏滚动条,同时又保证页面可以滚动? 使用 overflow:hidden 隐藏滚动条,但存在的问题是:页面或元素失去了滚动的特性.由于只需要兼容移动浏览器(Chrome 和 Safari),于是想到了自定义滚动条的伪对象选择器::-webkit-scrollbar. 关于这个选择器的介绍可以参考:Styling ScrollbarsCustom Scrollbars in WebKit 应用如下 CSS 可以隐藏滚动条: .element::-webki

egret:设置滚动视图、隐藏滚动条以及层级的问题

一.设置滚动视图 二.隐藏滚动条 三.层级问题 我将图中list列表内容添加到界面后,我发现右上角的关闭按钮失灵了, 第一反应是将这个按钮的层级设置到最高层, 但是我直接设置后,发现还是有问题. 最后找到原因,因为我将背景(包括关闭按钮)打了组, 将这个组给解组之后 在去设置该关闭按钮的层级后: 此时再去点击关闭按钮,就能正常关闭了. 原文地址:https://www.cnblogs.com/WentingC/p/8675492.html