修改的Andr​​oid的微调滴下来的零件尺寸的大小?零件、滴下、尺寸、大小

2023-09-04 12:17:18 作者:你快滚,趁我没说舍不得

我怎么能修改微调的下拉部分的大小? 做我必须做的,在XML或code本身?

解决方案

您不能改变微调的大小,因为它是默认的小部件。但是,你可以把它定义使用背景图片。这是我的code:

 <微调
    机器人:ID =@ + ID /微调
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =45dp
    机器人:drawSelectorOnTop =真
    机器人:layout_marginLeft =20dp
    机器人:layout_marginTop =5DP
    机器人:layout_marginRight =20dp
    机器人:layout_below =@ + ID / placeCity
    机器人:以下属性来=5dip
    机器人:背景=@可绘制/ myspinner_background
/>
 < ImageView的
       机器人:ID =@ + ID / imageView1
       机器人:layout_width =WRAP_CONTENT
       机器人:layout_height =WRAP_CONTENT
       机器人:layout_alignRight =@ + ID /微调
       机器人:layout_alignTop =@ + ID /微调
       机器人:layout_marginRight =5DP
        机器人:layout_marginTop =10dp
       机器人:SRC =@可绘制/下/>
 

  

这是写在XML。并呼吁myspinner_background.xml在绘制文件夹中的另一个文件。在那个,写这篇code:

 <形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
<中风
    机器人:颜色=#f269be
    机器人:宽=2DP/>
[固体
    机器人:颜色=#ECC8EC/>
 

how can i modify the size of the dropdown part of the spinner?? do i have to do that in XML or in the code itself?

解决方案

You can not change the size of spinner as it is default widget. But you can make it custom using background image. Here is my code:

<Spinner 
    android:id="@+id/spinner"
    android:layout_width="fill_parent" 
    android:layout_height="45dp"
    android:drawSelectorOnTop = "true"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="5dp"
    android:layout_marginRight="20dp"
    android:layout_below="@+id/placeCity"
    android:paddingLeft="5dip"
    android:background="@drawable/myspinner_background"
/>
 <ImageView
       android:id="@+id/imageView1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignRight="@+id/spinner"
       android:layout_alignTop="@+id/spinner"
       android:layout_marginRight="5dp"
        android:layout_marginTop="10dp"
       android:src="@drawable/down" />

This is written in XML. And make another file called myspinner_background.xml in drawable folder. Inside that, write this code:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
    android:color="#f269be"
    android:width="2dp" />
<solid
    android:color="#ECC8EC" />