简体   繁体   English

为什么我的Android边框无法显示?

[英]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.

相关问题 为什么我的DatePicker没有边框图形? - Why does my DatePicker have no border graphics? 为什么我的xamarin android无法显示图像而UWP无法显示图像? - Why does my xamarin android display images and UWP doesn't? 为什么我的角色转义符无法在Android设备上显示? - Why does my character escape not display on Android devices? 为什么我的Android微调框在textview中显示单选按钮? - why does my android spinner display the radio button in the textview? 为什么Android边框上的CSS边框看起来有所不同? - Why does a CSS border look different on Android? 边框未显示在我的图像中 - border not display in my images 为什么我的吐司不显示在模拟器上? - Why does my toast not display on my emulator? 为什么我的Android应用程序图标在不同的Android设备上显示不同?如何保持相同? - Why does my Android app icon display different in different Android device?how to keep it same? Android:为什么我的视图会填满整个屏幕而不显示底部的按钮 - Android: Why does my view fill the entire screen and not display the buttons at bottom 为什么即使使用视口/媒体查询,我的页面也无法在Android上以正确的大小显示? - Why Does My Page Not Display In The Right Size On An Android Even With Viewport/Media Queries?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM