Java 弹出窗口显示不正确

Java 弹出窗口显示不正确,java,android,android-layout,android-popupwindow,Java,Android,Android Layout,Android Popupwindow,我试图复制此视图的布局(不一定是编辑文本框的圆角矩形,只是宽度/布局): 暗显的背景色,编辑文本的宽度。然而,我得到的是: 没有透明的背景色,用户可以访问弹出窗口后面的视图,编辑文本会缩小。正在从片段调用此popupwindow 1。我不希望用户能够触摸调用片段,因此我使用了: mPopupWindow.setOutsideTouchable(false); 但是用户仍然可以访问弹出窗口后面的视图。我认为这是因为背景还没有确定。所以我这样做了: 下面是相关的代码片段(完整代码在底部) 2。

我试图复制此视图的布局(不一定是编辑文本框的圆角矩形,只是宽度/布局):

暗显的背景色,编辑文本的宽度。然而,我得到的是:

没有透明的背景色,用户可以访问弹出窗口后面的视图,编辑文本会缩小。正在从片段调用此popupwindow

1。我不希望用户能够触摸调用片段,因此我使用了:

mPopupWindow.setOutsideTouchable(false);
但是用户仍然可以访问弹出窗口后面的视图。我认为这是因为背景还没有确定。所以我这样做了:

下面是相关的代码片段(完整代码在底部)

2。对于背景色:

mPopupWindow.setOutsideTouchable(false);
在my colors.xml中,我有以下内容:

 < color name="COLOR_50_GREY" >#80636363</color> 
但是没有运气

3。缩小文本视图。根据

我应该能够使用以下内容创建加权线性布局(为清晰起见删除了明显的内容,底部有完整的代码):

弹出窗口XML

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/COLOR_LIGHT_GREY"
            android:padding="8dp"
            android:layout_margin="20dp"
            android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginBottom="5dp"
            android:orientation="horizontal"
            android:padding="3dp"
            android:weightSum="5">

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginEnd="4dp"
                android:layout_weight="1"
                android:text="TOW TICKET:"
                android:gravity="right|center_vertical"
                android:textAllCaps="true"
                android:textColor="@color/COLOR_BLUE"
                android:textIsSelectable="false"
                android:textStyle="bold"/>


            <EditText
                android:id="@+id/etTowTicketNumber"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:imeOptions="actionDone"
                android:inputType="text"
                android:maxLength="30"
                android:maxLines="1"
                />

            <Button
                android:id="@+id/btnNA"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:background="@color/COLOR_BLUE"
                android:padding="1dp"
                android:text="NA"
                android:textColor="@color/COLOR_WHITE"
                android:textSize="18sp"
                android:textStyle="bold"/>

        </LinearLayout>


//OTHER STUFF TRUNCATED FOR BREVITY 

    </LinearLayout>

</ScrollView>

//为简洁起见,其他内容被截断

您需要为编辑文本制作自定义可绘制设计,并将其设置为编辑文本背景,然后才能实现

<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >

    <solid android:color="#FFFFFF" />

    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />

</shape>

要以“输入值”的形式给出提示,请使用android:hint属性

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/COLOR_LIGHT_GREY"
            android:padding="8dp"
            android:layout_margin="20dp"
            android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginBottom="5dp"
            android:orientation="horizontal"
            android:padding="3dp"
            android:weightSum="5">

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginEnd="4dp"
                android:layout_weight="1"
                android:text="TOW TICKET:"
                android:gravity="right|center_vertical"
                android:textAllCaps="true"
                android:textColor="@color/COLOR_BLUE"
                android:textIsSelectable="false"
                android:textStyle="bold"/>


            <EditText
                android:id="@+id/etTowTicketNumber"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:imeOptions="actionDone"
                android:inputType="text"
                android:maxLength="30"
                android:maxLines="1"
                />

            <Button
                android:id="@+id/btnNA"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:background="@color/COLOR_BLUE"
                android:padding="1dp"
                android:text="NA"
                android:textColor="@color/COLOR_WHITE"
                android:textSize="18sp"
                android:textStyle="bold"/>

        </LinearLayout>


//OTHER STUFF TRUNCATED FOR BREVITY 

    </LinearLayout>

</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >

    <solid android:color="#FFFFFF" />

    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />

</shape>