手机微信通讯录右侧字母的实现:
新创建一个布局用来编辑我们所需要的字母部分,主要是应用相对布局里控件的排序的掌握,具体代码如下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_alignParentRight="true"
android:layout_width="10dp"
android:layout_height="match_parent">
<TextView
android:id="@+id/A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="\n\n\n↑A"></TextView>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
代码只举例出字母A的编辑方法,其余字母代码同理
其次在我们事先画好的通讯录布局,应用include 来引用我们的字母部分,即可实现向下滑动时,字母也跟随的滑动