今天在布局中添加了一条线,用到了<!-- <include layout="@layout/divider_horizontal" android:visibility="invisible"/> -->这个布局,但是在代码中设置viewLine.setVisibility(View.VISIBLE);并没有效果,然后将布局改成 <View
android:id="@+id/viewLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/divider_horizontal_bright"
android:visibility="invisible"
android:id="@+id/viewLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/divider_horizontal_bright"
android:visibility="invisible"
/>
效果就出来了,可以对viewLine进行操作,layout布局divider_horizontal布局的内容
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@drawable/divider_horizontal_bright" />
我认为是没有获取到id,但是具体原因还未了解,指导的留个言评论下,写下这文章给自己提个醒