Jea*_*nma 4 android android-spinner
在我的应用程序中,我在scrollView中有一些微调器(每个都是片段的一部分).此scrollView位于textView下方.
问题是,当我在我的测试设备(三星Galaxy S6 Edge [G925F],API 23)上运行应用程序时,微调器的小箭头在textView上方保持可见,即使其余的微调器已经是不合时宜.
我做了很多研究,但找不到任何解决方案,所以我在这里问: 我需要做什么才能让箭头像旋转器的其余部分一样消失?
这里有些图片:
在这张图片中,您可以在我向下滚动之前看到活动顶部和微调器下方的textView

在此屏幕截图中,您可以看到问题.微调器的小三角形仍然可见,但旋转器本身已经滚出视野.

以下是包含微调器的片段的XML代码:
<?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>
Run Code Online (Sandbox Code Playgroud)
这是MainActivitys内容的代码:
<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>
Run Code Online (Sandbox Code Playgroud)
片段通过Java方法添加到LinearLayout(@ id/layout).如果需要,我也会在这里发布.
我使用的是Java 1.8.05,目标SDK是23,最小值是14.代码是用Android Studio编写的
带有问题的textView是@id/textView,在顶部显示大号.
@jeanma你可以通过设置解决问题
android:background="#00FFFFFF"
Run Code Online (Sandbox Code Playgroud)
对于ScrollView的ScrollView或root LinearLayout
我现在已经有了一个解决方法。正如我所建议的,当我将 textView 的背景颜色设置为与我的活动相同时,箭头不再显示。但空间的表现确实不同。在那里它改变了一些东西,我改变了背景颜色。所以我就把它删除了。(看起来还是不错的)。
可以在此处查看 MainActivity 内容的更新 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<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">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:text="Standard text"
android:layout_height="wrap_content"
android:textSize="40dp"
android:gravity="end"
android:background="#FAFAFA"/>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView">
<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>
Run Code Online (Sandbox Code Playgroud)
但因为箭头显示也扔了填充物,所以我改变了我的
src\main\res\values\dimens.xml以下内容(我知道这是非常糟糕的做法):
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen><!-- This was changed from 16dp to 0dp -->
<dimen name="fab_margin">16dp</dimen>
</resources>
Run Code Online (Sandbox Code Playgroud)
感谢@ScriptKity @Wukash @Bryan 的支持