Android 微调箭头始终高于其他视图 [英] Android spinner arrow always above other views
问题描述
在我的应用程序中,我在 scrollView 中有一些微调器(每个微调器都是片段的一部分).此滚动视图位于 textView 下方.
In my app, I have some spinners (each of which is part of a fragment) in a scrollView. This scrollView is placed below a textView.
问题是,当我在我的测试设备(Samsung Galaxy S6 Edge [G925F],API 23)上运行应用程序时,微调器的小箭头在 textView 上方保持可见,即使其余的微调器已经不在视野范围内.
The problem is that, when I'm running the app on my test device (Samsung Galaxy S6 Edge [G925F], API 23), the little arrow of the spinner stays visible above the textView, even though the rest of the spinner is already out of view.
我做了很多研究,但找不到任何解决方案,所以我在这里问:我需要做什么才能使箭头像微调器的其余部分一样消失?
I did a lot of research but couldn't find any solutions, so I'm asking here: What do I need to do so that the arrows disappear like the rest of the spinner?
这里有一些图片:
在这张图片中,在我向下滚动之前,您可以在活动顶部和微调器下方看到 textView
In this picture, you can see the textView at the top of the activity and below the spinners, before I scrolled down
在此屏幕截图中,您可以看到问题.微调器的小三角形仍然可见,但微调器本身已经滚出视图.
In this screenshot, you can see the problem. The little triangles of the spinner are still visible, but the spinner itself is already scrolled out of view.
这是包含微调器的片段的 XML 代码:
Here is the XML code of the fragment containing the spinner:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:id="@+id/fragLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/gradeDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:text="1"
android:textSize="30dp"/>
<Spinner
android:id="@+id/spinner"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:entries="@array/grades"/>
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:src="@drawable/ic_remove_black_24dp"
android:background="@null"/>
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_height="5dp"
android:layout_below="@id/fragLayout"/>
</RelativeLayout>
这里是 MainActivitys 内容的代码:
And here is the code of the MainActivitys content:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.jeanma.android.avo.MainActivity"
tools:showIn="@layout/activity_main">
<Space
android:id="@+id/mainContentSpace"
android:layout_width="match_parent"
android:layout_height="16dp" />
<TextView
android:id="@+id/textView"
android:layout_below="@id/mainContentSpace"
android:layout_width="match_parent"
android:text="Standard text"
android:layout_height="wrap_content"
android:textSize="40dp"
android:gravity="end"/>
<ScrollView
android:id="@+id/scrollView"
android:layout_below="@id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/divider"
android:showDividers="middle">
</LinearLayout>
</ScrollView>
</RelativeLayout>
片段通过 Java 方法添加到 LinearLayout (@id/layout).如果需要,我也会在这里发布.
The fragments are added to the LinearLayout (@id/layout) by a Java method. If needed, I will post that here as well.
我使用的是 Java 1.8.05,目标 SDK 是 23,最小是 14.代码是在 Android Studio 中编写的
I'm using Java 1.8.05 and the target SDK is 23, the minimum is 14. The code is written in Android Studio
有问题的 textView 是 @id/textView
,在顶部显示大数字.
The textView with the problems is the @id/textView
, displaying the large number at the top.
推荐答案
@jeanma 您只需设置即可解决问题
@jeanma you can fix the issue with just setting
android:background="#00FFFFFF"
用于您的 ScrollView 或 ScrollView 的根 LinearLayout
for your ScrollView or root LinearLayout of the ScrollView
这篇关于Android 微调箭头始终高于其他视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!