使用对话框片段扩充视图

3

我使用对话框片段来填充一个视图。在 API 23+ 上一切正常,但是当我在 API 19 上测试时,我的视图上出现了一条蓝色的线。我甚至无法在我的 color.xml 文件中找到这条线的颜色。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B3000000"
android:orientation="vertical">
<TextView
    android:id="@+id/add_text_done_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_margin="20dp"
    android:background="@drawable/rounded_border_text_view"
    android:padding="10dp"
    android:text="Done"
    android:textAllCaps="false"
    android:textColor="@color/white"
    android:textSize="15sp" />

<EditText
    android:id="@+id/add_text_edit_text"
    style="@style/EditText"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/add_text_color_picker_relative_layout"
    android:layout_below="@+id/add_text_done_tv"
    android:background="@null"
    android:gravity="center"
    android:inputType="textMultiLine"
    android:textSize="40sp" />

<LinearLayout
    android:id="@+id/add_text_color_picker_relative_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_alignParentBottom="true">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/add_text_font_picker_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:background="@android:color/black"
        tools:listitem="@layout/font_picker_list_item" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/add_text_color_picker_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:background="@android:color/black"
        tools:listitem="@layout/color_picker_item_list" />


</LinearLayout>

</RelativeLayout>

我在我的类的onStart()方法中添加了以下代码以设置布局的大小。

        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setLayout(width, height);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

This is the image of my problem.

2个回答

1

1

你应该隐藏标题:

dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接