코드에서 팝업 창을 표시하여 화면에서 터치 한 위치에 상관없이 내가 터치 한 위치 바로 위에 팝업이 나타나야합니다. . 확실하지 않은, 이것을 달성하는 방법. 이것은 내 popup.xml입니다화면에서 건 드린 장소 바로 위에 팝업 창을 표시하려면 어떻게합니까?
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.popup,null);
final PopupWindow popupWindow = new PopupWindow(
customView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
// Set an elevation value for popup window
// Call requires API level 21
if(Build.VERSION.SDK_INT>=21){
popupWindow.setElevation(5.0f);
}
final TextView placename = (TextView) customView.findViewById(R.id.popup_id) ;
Button closeButton = (Button) customView.findViewById(R.id.directions);
placename.setText(place.getName());
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
// Set a click listener for the popup window close button
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Dismiss the popup window
popupWindow.dismiss();
}
});
popupWindow.setFocusable(true);
popupWindow.showAtLocation(mapInsideContainer, Gravity.CENTER, 0, 0);
popupWindow.showAsDropDown(customView);
: 이것은 내 현재 팝업 창 코드
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_light">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="@android:color/white">
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="20dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:id="@+id/popup_id" />
<Button
android:id="@+id/directions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/black_overlay"
android:textColor="@android:color/white"
android:text="Directions" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
는 현재이 때문에 Gravity.CENTER로 화면 중앙에 표시됩니다,하지만 난 보여 드리고자합니다 내가 화면에서 동적으로 터치하는 곳 바로 위. 어떤 아이디어? 덕분에 당신은 위치에 거품 포인터 하단에 상단에 제목과 "장소"버튼을 팝업과 같은 채팅 거품을 만드는 과정 나를 인도 할 수
보너스 포인트 경우 PopupWindow를 사용하는
당신은 부분이 혼란 투명 활동으로 도움이 될 것입니다 자세한 도움을 줄 수 그리고 난 그 팝업 창이 바로 표시하지 않는 문제를 해결 얼마나 아무 생각이없는 경우 터치 포인트 위 –
@ JusticeBauer 나는 몇 가지 세부 사항을 제공하기 위해 나의 대답을 편집했다. 오늘 밤 더 편집 하겠지만 지금 가야합니다. –
@ JusticeBauer 더 자세한 내용을 추가했습니다. –