Kok*_*sho 8 mobile android scrollbar scrollview nestedscrollview
嘿我在Activity中实现了一个NestedScrollView,但是我不能像在ScrollView中那样显示滚动条,你们可以.
我怎么展示它?
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appBar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingLeft="@dimen/dimen_2"
android:paddingRight="@dimen/dimen_2">
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
Mic*_*son 17
使用android:scrollbars属性.
如:
机器人:滚动条="垂直"
机器人:滚动条="水平"
机器人:滚动条="垂直|水平"
<android.support.v4.widget.NestedScrollView
android:id="@+id/foo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
文档链接:https://developer.android.com/reference/android/view/View.html#attr_android : scrollbars
我找到了解决方案,首先将 NestedScrollView 行为设置为“@string/appbar_scrolling_view_behavior”,然后我创建了一个样式来在我需要的所有 NestedScrollView 中显示滚动条。
在styles.xml:
<resources>
<!-- other styles -->
<style name="NestedScrollBarStyle">
<item name="android:scrollbarFadeDuration">2</item>
<item name="android:scrollbars">vertical</item>
<item name="android:fillViewport">true</item>
<item name="android:orientation">vertical</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
在布局中:
<android.support.v4.widget.NestedScrollView
style="@style/NestedScrollBarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appBar"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingLeft="@dimen/dimen_2"
android:paddingRight="@dimen/dimen_2">
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7184 次 |
| 最近记录: |