在nexus 7和三星galaxy s4中,弹出窗口没有全屏显示?

时间:2013-08-02 12:06:22

标签: android view

按下按钮时,我需要在操作栏中的按钮(菜单)下方显示弹出窗口。除了Nexus 7和三星galaxy S4之外,所有设备上的一切都运行良好。令人惊讶的问题是Pop窗口没有填满整个屏幕。我在上面提到的高分辨率设备中发现了这个问题。在这里,我附加了屏幕截图,清楚地显示了问题。enter image description here

因此,当用户按下菜单时,我正面临着从左侧测量箭头的位置问题,我需要计算以动态移动箭头。在这里,我很难将箭头显示在操作栏上单击的菜单下方。

问题

1)虽然布局参与者是父母,但是弹出窗口没有填充设备屏幕 2)箭头向右移动,移动距离等于屏幕最左侧的间隙。

我的内容

更多是操作栏上的点击视图(菜单)

    more.getLocationOnScreen(xy);
    int[] parentxy = new int[2];
    ((LinearLayout) aerrowHead.getParent()).getLocationOnScreen(parentxy);
    final Rect rect = new Rect();
    rect.left = xy[0];
    Log.v("More", "Left :" + xy[0] + "bottom" + xy[1]);
    Log.v("arrow head parent", "Left :" + parentxy[0] + "bottom"
            + parentxy[1]);
    rect.top = xy[1] - more.getWidth() / 2;
    rect.right = xy[0] + more.getWidth();
    rect.bottom = xy[1] + more.getHeight() / 2;
    popup.showAsDropDown(more);
    android.widget.LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);

    int marginLeft = xy[0] - parentxy[0] + more.getWidth() / 2
            - aerrowHead.getWidth() / 2;
    layoutParams.setMargins(marginLeft, 0, 0, 0);

    aerrowHead.setLayoutParams(layoutParams);
    popup.setFocusable(true);

和布局

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:layout_marginTop="8dp"
    android:background="@color/notification_panel_bgcolor"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/txtNotificationTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Notification"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#4A546C" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:cacheColorHint="@null"
            android:divider="#C7C7C8"
            android:dividerHeight="1dp"
            android:listSelector="@null"
            android:visibility="gone" >
        </ListView>

        <LinearLayout
            android:id="@+id/errorLoadingLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:orientation="horizontal"
            android:visibility="visible" >

            <ImageView
                android:id="@+id/errorLoadingImage"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_friendrequest"
                android:visibility="gone" />

            <ProgressBar
                android:id="@+id/load_more_progressbar"
                style="?android:attr/android:progressBarStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/txtErrorLoading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:background="@android:color/transparent"
                android:gravity="center"
                android:shadowColor="#ffffff"
                android:shadowDy="2"
                android:shadowRadius="0.3"
                android:text="Error In Loading"
                android:textColor="#576586"
                android:textSize="14sp"
                android:textStyle="bold" />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top" >

    <ImageView
        android:id="@+id/aerrowHead"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_notification_popup_arrowhead" />
</LinearLayout>

0 个答案:

没有答案