android中颜色不显示

在入手安卓的时候,你是不是也有这样的苦恼,明明一样的代码,为啥在颜色view的颜色不显示,而LinearLayout中的背景颜色显示,你如果在哪里安卓颜色的取值类型就跑偏了,作为一个初学者,这不是我们应该考虑的,尝试看一下大小写,没错,View!上代码。

错误的:

  <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="16dp"
        android:orientation="horizontal"
        android:background="#000000"
        android:padding="5dp">
        <view
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/colorPrimary" />

        <view
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#002233" />
    </LinearLayout>

来!我们改成正确的:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="16dp"
        android:orientation="horizontal"
        android:background="#000000"
        android:padding="5dp">
        <Viewiew
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/colorPrimary" />

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#002233" />
    </LinearLayout>

我也是服了,其实这是很现实的问题,老师们一般不会犯这样低级的错误,就一带而过了,其实在我们输入v没给出提示的时候我们就应该发现猫腻,就是初学,不规范的地方太多,共勉啊!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值