Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的旋转器看起来不像旋转器?_Android_Android Layout_Android Spinner - Fatal编程技术网

Android 为什么我的旋转器看起来不像旋转器?

Android 为什么我的旋转器看起来不像旋转器?,android,android-layout,android-spinner,Android,Android Layout,Android Spinner,我有一个看起来非常难看的旋转器: 当我点击它时,它看起来好一点: 但是,在默认情况下,它甚至不像一个旋转器。你知道我该如何改善它的外观吗 代码如下: adapter=new SpinAdapter(this,com.Orange.R.layout.spinnerrowlist,spinnerInfo); adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item); previousV

我有一个看起来非常难看的旋转器:

当我点击它时,它看起来好一点:

但是,在默认情况下,它甚至不像一个旋转器。你知道我该如何改善它的外观吗

代码如下:

adapter=new SpinAdapter(this,com.Orange.R.layout.spinnerrowlist,spinnerInfo);
adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
previousVisitCommentsSpinner.setAdapter(adapter);
spinnerrowlist.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:background="#FFFFFF"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textview_spinner1"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="5dp"
        android:layout_alignParentLeft="true"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner2"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_toRightOf="@+id/textview_spinner1"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner3"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

</RelativeLayout>

这是旋转器:

<Spinner
    android:id="@+id/previousVisitComments"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_below="@+id/previousvisit"
    android:layout_marginTop="15dp"
    android:background="@drawable/spinner_selector"
    android:textColor="@color/medium_orange"
    android:textAppearance="?android:attr/textAppearanceMedium"
    />

微调器中的项目应该在同一行上,这就是我使用水平布局的原因 谢谢你的回答

试试添加这个

android:layout_toRightOf="@+id/textview_spinner1 
您还可以添加以下内容,看看这是否会有所不同

android:layout_below 
让我知道进展情况:)

微调器中的项目应该在同一行上,这就是我使用水平布局的原因

问题是,您试图将大量文本压缩到一个狭窄的区域中。但是,您有两种选择:

首先使用您现有的,只需将
layout\u-toLeftOf
属性添加到
textview\u喷丝头2

<TextView
    android:id="@+id/textview_spinner2"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_toLeftOf="@+id/textview_spinner3"
    android:layout_toRightOf="@+id/textview_spinner1"
    android:paddingLeft="5dp" />
子元素的组织由单个属性确定,例如:
layout\u-toLeftOf
layout\u-toRightOf
layout\u-toRightOf
layout\u-toRightOf

Second如果你的RelativeLayout行为不规则,并且你有这样一个简单的布局,你总是可以切换到LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp" >

    <TextView
        android:id="@+id/textview_spinner1"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner2"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner3"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

</LinearLayout>


现在,微调器中的所有列都不重叠。

您可以在Java代码中尝试(android.R.layout.simple\u微调器\u下拉项)。希望这能有所帮助,而不是(com.Orange.R.layout.multiline\u spinner\u dropdown\u项目)。

键在com.Orange.R.layout.spinnerrowlist中,而不是下拉列表中。现在看不见;如果我有空的话,我会试着稍后再看,但它试图将文本压缩到一个小区域。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp" >

    <TextView
        android:id="@+id/textview_spinner1"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner2"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

    <TextView
        android:id="@+id/textview_spinner3"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:paddingLeft="5dp"
        android:textColor="@drawable/textorange_selected" />

</LinearLayout>