Disappearing dividers in Spinner drop-down list

2019-06-09 23:23发布

I am writing my first simple Android App: It loads temperature samples from a Java based measurement system (CSV via HTTP), shows the available channels in a Spinner and when a channel is selected, it shows the corresponding value and a timestamp in two TextViews. The App works fine, except a little cosmetic problem: The items in the drop-down list are separated by a horizontal line (divider) and depending on the scroll position, some lines disappear and appear again, when I scroll some more pixels up or down. The phenomenon happens on the emulator screen as well as on the handheld display (HTC Wildfire). Seems to be a screen resultion problem. Does anyone have a hint how to avoid this? Please see my code below...

Thanks, gemue

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    loadData();
    setContentView(R.layout.main);
    Spinner spinner = (Spinner) findViewById(R.id.Spinner01);
    ArrayAdapter adapter = new ArrayAdapter(this,
            android.R.layout.simple_spinner_dropdown_item, channels);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new SelectListener());
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">
    <Spinner android:id="@+id/Spinner01"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:layout_margin="15px"/>
    <TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_below="@+id/Spinner01"
          android:textSize="40sp" android:textStyle="bold"
          android:layout_margin="15sp"/>
    <TextView android:text="@+id/TextView02" android:id="@+id/TextView02"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_below="@+id/TextView01"/>
</RelativeLayout>

1条回答
时光不老,我们不散
2楼-- · 2019-06-10 00:11

Just check whether this will solve the issue.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens
    android:largeScreens="false"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true" />
</manifest>
查看更多
登录 后发表回答