我想像ImageView一样使用
<ImageView
android:layout_width="match_parent"
android:layout_height="0.4dp"
android:background="@color/bottomline" />
但是 android:layout_height =&#34; 0.4dp &#34; 是错误的!
错误: 可疑大小:这会使视图不可见,应与layout_weight一起使用。
我发现如果 imageview是LinearLayout中的第一个视图 ,则会出现错误,就像这样
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgroundcolor"
android:orientation="vertical" >
<!-- first view error -->
<ImageView
android:layout_width="match_parent"
android:layout_height="0.4dp"
android:layout_marginTop="10dp"
android:background="@color/bottomline" />
<!-- second view right -->
<ImageView
android:layout_width="match_parent"
android:layout_height="0.4dp"
android:layout_marginTop="10dp"
android:background="@color/bottomline" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="10dp"
android:text="李文"
android:textColor="@color/black_text_color"
android:textSize="16sp" />
如何解决问题?
答案 0 :(得分:0)
如果想要细线,你应该尝试在px
给出高度。
答案 1 :(得分:0)
诀窍不是使用&#34; wrap_content &#34;或&#34; fill_parent &#34;对于您正在设置权重的控件。而是将layout_height设置为 0px (当在垂直布局内时),然后子控件将按权重值进行比例
将 layout_height 更改为 1dp