布局文件:activity_search

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.cjxj.androiddemo.activity.SearchActivity">

<RelativeLayout
android:id="@+id/search_rl_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#3F51B5">

<RelativeLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="44dp">

<ImageView
android:id="@+id/search_iv_back"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="@drawable/video_back" />

<TextView
android:id="@+id/search_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="11.5dp"
android:gravity="center"
android:text="这是标题"
android:textColor="#fff"
android:textSize="17dp"
android:textStyle="bold" />

</RelativeLayout>

<LinearLayout
android:id="@+id/search_ll_search"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="49dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="10dp"
android:background="@drawable/activity_search_tv_shape"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="visible">

<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_search" />

<TextView
android:id="@+id/search_tv_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:cursorVisible="false"
android:gravity="center_vertical|center_horizontal"
android:hint="这是搜索框"
android:textSize="15dp" />

<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_search" />

</LinearLayout>

</RelativeLayout>

<com.cjxj.androiddemo.view.AnimationNestedScrollView
android:id="@+id/search_sv_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/search_rl_top">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="900dp" />

</LinearLayout>

</com.cjxj.androiddemo.view.AnimationNestedScrollView>


</RelativeLayout>

1
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
这里的布局文件是实现安居客的效果的代码,如果要实现京东的效果,布局文件只需要设置search_ll_search的属性即可:

删除代码:

android:layout_centerHorizontal="true"
1
添加代码:

android:layout_alignParentLeft="true"
1
然后再修改逻辑代码参数即可,后面会介绍。
————————————————

posted @ 2019-08-20 18:10  李艳艳665  阅读(123)  评论(0编辑  收藏  举报