【问题标题】:Spinner Element not showing proper view before selection微调器元素在选择之前未显示正确的视图
【发布时间】:2017-05-04 05:15:43
【问题描述】:

在此处输入图像描述[我有 4 个 Spinner,选择第一个 Spinner 后,第二个 Spinner 项目将出现。当我打开页面时,它显示为图像,第一个文本在适当的位置,但第三个元素有一些间隙,当我选择时我的第一个项目然后第二个项目会自动从它的列表中取出一个,并且没有我在图像中提到的间隙。请帮我解决这个问题。

我的布局中的这个微调器

    <Spinner

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:entries="@array/subloc"
            android:gravity="left"
            android:paddingBottom="5dp"
            android:paddingTop="10dp"
            android:textSize="18sp"

            />

微调项目是:

   <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#000"
android:textSize="15sp"
android:text="dvvdv"/>

]

【问题讨论】:

  • 尝试从“Select Subnature”字符串中删除空格或从该微调器的原始文件中删除填充。
  • 没有任何左填充
  • 设置 Spinner 前提示修剪内容并设置。
  • 您是否对所有微调器使用相同的视图?
  • Android 显示器有 Layout Inspector,您可以轻松找到问题所在。它将提供有关您的视图的所有信息。从那里你可以得到那个差距的起源。

标签: android alignment spinner


【解决方案1】:

第一步: 尝试使用默认的 android.R.layout.simple_spinner_dropdown_item 作为微调器下拉,它将完美显示而没有任何空间 否则

//第二步

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:id="@+id/spinner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" 
   android:hint="Select item"
   android:background="@drawable/spin"/>

</RelativeLayout>

【讨论】:

  • 我有不同的文字样式。
  • 我有微调项的问题,而不是下拉项
  • @Trisha..哦,这很酷......如果你有解决方案,请投票给我 :) 提前致谢
【解决方案2】:

尝试如下更改 Spinner Item。

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textColor="#000"
        android:paddingTop="15dp"
        android:paddingBottom="15dp"
        android:textSize="15sp"
        android:text="dvvdv"/>

【讨论】:

  • 底部或顶部没有问题,左侧有问题,在选择之前。如果我选​​择父项,则子项以完美视图显示
【解决方案3】:

您可能在 Select Subnature String 之前添加了空格。尝试删除该空间。

【讨论】:

  • 不,我没有添加任何空格
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-22
相关资源
最近更新 更多