アクションバーのボタン(メニュー)を押したときに、その下にポップアップウィンドウを表示する必要があります。Nexus 7 と Samsung Galaxy S4 を除くすべてのデバイスですべて正常に動作しています。驚くべき問題は、ポップ ウィンドウが画面全体に表示されないことです。上記のような高解像度デバイスでこの問題が見つかりました。ここに、問題を明確に示しているスクリーンショットを添付しました。
その結果、ユーザーがメニューを押したときに矢印の頭を動的にシフトするために計算する必要がある左から矢印の頭の位置を測定する際に問題に直面しています。ここで、アクションバーのクリックされたメニューの真下に矢印の頭を表示する際に問題が発生しています。
問題
1) レイアウト ベビーカーが親に一致しているにもかかわらず、ポップ ウィンドウがデバイス画面でいっぱいにならない 2) 矢印の頭が右に移動し、移動距離が画面の最も左側のギャップに等しい。
私がしたこと
more は、アクションバーのクリックされたビュー (メニュー) です
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>