我在这里尝试了所有解决方案,但似乎所有解决方案都不适合我。
下面的代码在Android Kitkat上运行良好,但是在Oreo 8.1中,无论我尝试哪种样式,在Dialogfragment之下总是有丑陋的黑色块
调用对话框的代码:
FragmentManager pfm = getFragmentManager();
NewPointMapPopup pointSaveDialog = new NewPointMapPopup();
Bundle args = new Bundle();
args.putParcelable("newPoint", tapLoc);
args.putInt("screenX",Math.round(canvasX));
args.putInt("screenY",Math.round(canvasY));
args.putInt("screenHeight",canvasHeight);
pointSaveDialog.setArguments(args);
pointSaveDialog.show(pfm, "");
onCreateView上的代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.new_point_map_popup, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
和布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_main_layout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/map_popup_bg"
android:padding="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:gravity="right"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="Latitude:"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="Longitude:"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="Distance:"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/new_point_lat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="43.1231233"/>
<TextView
android:id="@+id/new_point_lon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="25.55656666"/>
<TextView
android:id="@+id/new_point_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foretrexBlue"
android:text="250 m"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:weightSum="2"
android:orientation="horizontal">
<Button
style="@style/MFButton"
android:id="@+id/new_point_close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_weight="1"
android:text="Close"/>
<Button
style="@style/MFButton"
android:id="@+id/new_point_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"/>
</LinearLayout>
</LinearLayout>
最佳答案
显然这是Android Oreo 8.1错误。从2018年10月5日开始更新后,此问题已解决。