简体   繁体   中英

Why does my android border not display?

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:

      <?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. But If LinearLayout have very much child controls, border can't display. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM