android 一些通用View

本文将深入探讨Android开发中的一种常见组件——DividerLineLinearLayout,它常用于在列表或布局中添加分隔线,提升界面清晰度。我们将讨论其使用方法、自定义属性以及在实际项目中的应用。
摘要由CSDN通过智能技术生成

1. DividerLineLinearLayout

import android.content.Context ;
import android.content.res.TypedArray ;
import android.graphics.Canvas ;
import android.graphics.drawable.Drawable ;
import android.util.AttributeSet ;
import android.view.View ;
import android.widget.LinearLayout ;

/**
* Created by whuthm
* 分隔线线性布局
*/
public class DividerLineLinearLayout extends LinearLayout {
   
    private int mDividerTopMargin;
    private int mDividerBottomMargin ;
    private int mDividerLeftMargin ;
    private int mDividerRightMargin ;
   
    private Drawable mDividerDrawable;
    private int mDividerWidth ;
    private int mDividerHeight ;
   
    private boolean mDrawStart ;
    private boolean mDrawEnd ;
   
    public DividerLineLinearLayout(Context context) {
        this (context, null) ;
    }
   
    public DividerLineLinearLayout(Context context , AttributeSet attrs) {
        super (context, attrs) ;
       
        setWillNotDraw( false);
       
        final TypedArray a = context.obtainStyledAttributes(attrs ,
                R.styleable.DividerLinearLayout) ;
        mDividerDrawable = a.getDrawable(R.styleable.DividerLinearLayout_android_divider );
        mDividerWidth = a.getDimensionPixelSize(
                R.styleable.DividerLinearLayout_dividerWidth, 0 );
        mDividerHeight = a.getDimensionPixelSize(
                R.styleable.DividerLinearLayout_android_dividerHeight, 0 );
       
        final int horMargin = a.getDimensionPixelSize(
                R.styleable.DividerLinearLayout_dividerHorMargin, 0 );
        final int verMargin = a.getDimensionPixelSize(
                R.styleable.DividerLinearLayout_dividerVerMargin, 0 );
        mDividerTopMargin = a.getDimensionPixelSize(
                R.styleable.DividerLinearLayout_dividerTopMargin, verMargin) ;
        mDivide
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值