WindowManager仅显示背景

时间:2013-12-20 16:32:30

标签: android window-managers

我有RelativeLayout,我想在Window中显示。 我是这样做的:

    static WindowManager wManager;    

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN, android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN, android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT);
                wManager = (WindowManager) activity_home.getSystemService(Context.WINDOW_SERVICE);
                LayoutInflater inflater = (LayoutInflater) activity_home.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                RelativeLayout view =  (RelativeLayout) inflater.inflate(R.layout.order_wait, null);
    wManager.addView(view, params);

但我只看到RelativeLayout的背景,并没有看到它的内容。

order_wait.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
     >

    <LinearLayout
        android:id="@+id/ll_oder"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/gray_without_corners"
        android:orientation="vertical" 
        android:layout_marginTop="80dp"
        >

        <FrameLayout
            android:id="@+id/fr_poisk"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp" >

            <TextView
                android:id="@+id/txt_poisk"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Автомобиль будет через:"
                android:textColor="#000000"
                android:textSize="20sp"
                android:textStyle="bold" />
        </FrameLayout>

        <TextView
            android:id="@+id/txt_timer"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="0:30"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#111111"
            android:textSize="60sp"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_bot"
        android:layout_width="match_parent"
        android:layout_height="65dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:background="#B6B6B6" >

        <Button
            android:id="@+id/bt_cancel"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginTop="4dp"
            android:layout_weight="1"
            android:background="@drawable/but_yellow"
            android:text="ОТМЕНА"
            android:textColor="#1e90ff"
            android:textSize="20dp" />
    </LinearLayout>

</RelativeLayout>

感谢您的回答。

1 个答案:

答案 0 :(得分:0)

对于inflater.inflate(R.layout.order_wait, null),您可以尝试以root身份提供wManager而不是null吗?