【问题标题】:Top border wont show up顶部边框不显示
【发布时间】:2013-07-12 02:37:23
【问题描述】:

我的顶部边框不显示,它被放在另一个布局后面,我怎样才能让它出现?

这是我需要的图片,因为我还不能发布图片http://tinypic.com/r/33nhk4k/5

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/AliceBlue" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@color/Blue"
    android:gravity="top" >

</LinearLayout>

</RelativeLayout>

【问题讨论】:

    标签: android xml layout android-gui


    【解决方案1】:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/AliceBlue" >
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="@color/Blue"
        android:gravity="top" >
    
    </LinearLayout>
    
    </RelativeLayout>
    

    设置LinearLayout的宽度和高度或添加一些视图。

    【讨论】:

      【解决方案2】:

      确保在RelativeLayout中首先添加蓝色边框,首先添加的内容都会呈现在顶部。

      Z-index in android?

      【讨论】:

      • 那我该怎么做呢?你看到照片了吗?
      【解决方案3】:

      您将重力顶部赋予线性布局。所以它高于相对布局。对两种布局都使用 android:id 。第二个布局必须低于第一个布局。所以使用下面的布局属性。

      【讨论】:

        【解决方案4】:

        您看不到LinearLayout,因为它的宽度和高度设置为wrap_content,并且没有内容。

        【讨论】:

          【解决方案5】:

          brillenheini 有答案。如果您想查看边框,请给它一些高度(例如 20dp),因为没有内容的环绕内容将没有任何高度。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2022-11-18
            • 2021-10-27
            • 2021-10-02
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多