微调器具有自定义背景和三角形

问题描述 投票:0回答:2

Android 6.0 +,Java 1.8。在我的Android应用程序中。

这是我的自定义布局xml:

        <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:binding="http://www.gueei.com/android-binding/"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/containerAmount"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_margin="16dp" >

            <EditText
                android:id="@+id/send_editAmount"
                android:layout_width="0dip"
                android:layout_height="40dip"
                android:layout_weight="0.7"
                android:background="@drawable/backwithborder_notfocus"
                binding:text="amount" >
            </EditText>

            <View
                android:layout_width="8dip"
                android:layout_height="wrap_content" />

            <RelativeLayout
                android:id="@+id/rl"
                android:layout_width="0dip"
                android:layout_height="40dip"
                android:layout_weight="0.3"
                android:background="@drawable/backwithborder_notfocus" >

                <Spinner
                    android:id="@+id/currencySpinner"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </RelativeLayout>
        </LinearLayout>

        </LinearLayout>
</LinearLayout>

在这里我的自定义drawable backwithborder_notfocus.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <!-- background color -->
    <solid android:color="#FAFAF8" />

    <stroke
        android:width="1dip"
        android:color="#CCCCCC" />

</shape>

这是Android 6.0的结果

enter image description here

如你所见,三角形不在角落里。还有一个底线。我怎么解决这个问题?编辑文本具有相同的背景。

android spinner
2个回答
0
投票

解:

改变这个:

 <Spinner
     android:id="@+id/currencySpinner"
     android:layout_width="wrap_content"
     android:layout_height="match_parent" />

至:

<Spinner
     android:id="@+id/currencySpinner"
     android:layout_width="match_parent"
     android:layout_height="match_parent" />

希望能帮助到你。


0
投票

我找到了解决方案

    <RelativeLayout
        android:id="@+id/rl"
        android:layout_width="0dip"
        android:layout_height="40dip"
        android:layout_weight="0.3"
        android:background="@drawable/racommon_backwithborder_notfocus" >

    <Spinner
        android:id="@+id/currencySpinner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@null" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_action_popup" />
</RelativeLayout>

现在就像我想要的那样:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.