[英]Why does my android border not display?
border.xml: border.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke
android:width="1dip"
android:color="#cbcbcb" />
<corners android:radius="7dp" />
</shape>
Set Background of LinearLayout: 设置LinearLayout的背景:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="vertical" >
//Child control
</LinearLayout>
If LinearLayout has some child control: border display ok. 如果LinearLayout具有某些子控件:边框显示正常。 But If LinearLayout have very much child controls, border can't display. 但是,如果LinearLayout有很多子控件,则边框将无法显示。 Why border not display? 为什么边框不显示? how set border in this case? 在这种情况下如何设置边框?
because of this line : 由于这一行:
android:layout_height="wrap_content"
when the LinearLayout doesn't have a child so wrap_content in android:layout_height
cause that LinearLayout height to 0dp and nothing gonna show.set some size to your Layout and border will show up. 当LinearLayout没有子对象时, android:layout_height
wrap_content会导致LinearLayout的高度为0dp而不会显示任何内容。为您的Layout和border设置一些大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.