Androidstudio自定义控件,快速索引联系人的首字母条,效果图及代码详解


效果图:实际开发中除了部分服务性的需要使用模拟器调试外,我们基本都使用真机调试,体验效果更好,便于测试

自定义代码开发顺序一般是先mainActivi 再创建自定义View类,写UI,再开发,各位同僚也是比较清楚了,我就不献丑了,代码我就先放UI了

activity_main.xml

<?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.jms0313.quickindex.MainActivity">

    <ListView
        android:id="@+id/lv_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <com.jms0313.quickindex.QuickView.QuickView
        android:id="@+id/quick_bar"
        android:layout_width="30dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:background="#ff0000">

    </com.jms0313.quickindex.QuickView.QuickView>
    <TextView
        android:visibility="gone"
        android:id="@+id/tv_show"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="A"
        android:gravity="center"
        android:layout_centerInParent="true"
        android:textColor="#ffffff"
        android:textSize="50sp"
        android:background="@drawable/tv_circle"/>


</RelativeLayout>


adapter_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView
        android:id="&
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值