【问题标题】: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的宽度和高度或添加一些视图。
【解决方案3】:
您将重力顶部赋予线性布局。所以它高于相对布局。对两种布局都使用 android:id 。第二个布局必须低于第一个布局。所以使用下面的布局属性。
【解决方案4】:
您看不到LinearLayout,因为它的宽度和高度设置为wrap_content,并且没有内容。
【解决方案5】:
brillenheini 有答案。如果您想查看边框,请给它一些高度(例如 20dp),因为没有内容的环绕内容将没有任何高度。