问题描述:
【Android版本】:Android 8.1.0
【预置条件】在时钟界面添加多个不同国家世界时钟
【操作步骤】
1.竖屏下滑动查看
2.切换至横屏滑动查看
【实际结果】
2.横屏下出现滑动条不动,时钟界面自己在不停的更新,见视频
【期望结果】
横屏下可正常滑动查看
问题分析:
1) 找到滑动的View的布局代码在
竖屏是布局:packages/apps/DeskClock/res/layout/clock_fragment.xml1
2
3
4
5
6
7
8
9
10
11<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cities"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="false"
android:clipToPadding="false"
android:paddingBottom="@dimen/fab_height"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
横屏的布局:packages/apps/DeskClock/res/layout-land/clock_fragment.xml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Left gutter. -->
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="@integer/gutter_width_percent" />
<!-- Clock: 62% of total width (4% given to right gutter). -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="62"
android:gravity="center"
android:paddingBottom="@dimen/fab_height">
<include
android:id="@+id/main_clock_left_pane"
layout="@layout/main_clock_frame"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="29" />
<!-- Right gutter. -->
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />
</LinearLayout>
<!-- World Clock List: 33% of total width. Right gutter is applied in world_clock_item. -->
<android.support.v7.widget.RecyclerView
android:id="@+id/cities"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="33"
android:clickable="false"
android:clipToPadding="false"
android:paddingBottom="@dimen/fab_height"
android:paddingTop="16dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
</LinearLayout>
Java代码实现滑动:packages/apps/DeskClock/src/com/android/deskclock/ClockFragment.java