这是我的布局,它是一个信息窗口,它显示在有新信息要显示给用户的位置。
布局应该采用一些透明背景颜色和小文本布局的整个屏幕:
<?xml version="1.0" encoding="utf-8"?>
<!-- info fragment - used by the fragment to provide info on a specific fragment -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.coapps.pico"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_dark_green" >
//this is the only layout i see in the result. not it's parent's layout...
<RelativeLayout
android:id="@+id/fragment_info_relativelayout_info"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:background="@drawable/background_info_window"
android:clickable="true" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_margin="5dp" >
<!-- The info textView -->
<com.coapps.pico.NillanTextView
android:id="@+id/fragment_info_textview_info"
style="@style/text_shadow_black"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left"
android:text="Some Text "
android:textColor="@android:color/white"
app:isBold="true" />
</ScrollView>
<!-- Tap to close -->
<com.coapps.pico.NillanTextView
android:id="@+id/fragment_info_textview_tap_to_close"
style="@style/text_shadow_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="right"
android:paddingRight="5dp"
android:text="@string/button_tap_to_close"
android:textColor="@android:color/white"
app:isBold="true" />
</RelativeLayout>
</RelativeLayout>
我正在将此布局添加到另一个 ViewGroup 中,如下所示:
/**
* Show the info window
*/
public void show()
{
//if the window is not visible
if (!isVisible())
//add window's view
rootView.addView(infoWindowView);
}
此代码将信息窗口添加到最后一个索引中的根视图容器中。
结果我只看到包含文本的第二个RelativeLayout,但我没有看到它应该是透明的父根布局......
任何想法为什么?
更新: 这是我的容器:
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the main layout of the application -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_basic_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</RelativeLayout>