android--XML中画横线、竖线和虚线

一、画横线

<View
     android:layout_width="match_parent"
     android:layout_height="@dimen/border_line"
     android:background="#000000" />


二、画竖线

<View
     android:layout_width="1dp"
     android:layout_height="match_parent"
     android:background="#000000" />


三、画虚线
在drawable中新建一个dash_line.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke
    android:color="#000000"
    android:dashWidth="3dp"
    android:dashGap="5dp"/>
    <!--width:线条的高度
    color:颜色
    dashWidth:破折线的宽度
    dashGap:破折线间空隙的宽度
    如果这里设置了width,xml中android:layout_height的值必须比它大。不设置就默认为0
    -->
</shape>


在布局文件中使用
 

<View
     android:layout_width="match_parent"
     android:layout_height="2dp"
     android:layerType="software"
     android:background="@drawable/dash_line"/>

四、android控件drawableLeft图片大小控制

private void setDrawLeft(EditText editText,int res){
        Drawable drawable = getResources().getDrawable(res);
        drawable.setBounds(0,0,100,100);
        editText.setCompoundDrawables(drawable,null,null,null);
    }
setBounds(x,y,width,height); x:组件在容器X轴上的起点 y:组件在容器Y轴上的起点 width:组件的长度 height
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值