我尝试更改微调器内的滚动条的样式和位置,但它不起作用。
MainActivity.java:
package com.example.testapp;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
活动主.xml:
<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">
<Spinner
android:entries="@array/items"
android:verticalScrollbarPosition="left"
android:scrollbarThumbVertical="@drawable/scrollbar_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
可绘制/滚动条样式.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FF196C96" />
<corners android:radius="5dp" />
<size android:width="2dp" />
</shape>
值/字符串.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestApp</string>
<string name="action_settings">Settings</string>
<string-array name="items">
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
<item>Item 5</item>
<item>Item 6</item>
<item>Item 7</item>
<item>Item 8</item>
<item>Item 9</item>
<item>Item 10</item>
</string-array>
</resources>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
截屏:
请注意,如果我将它们与 a 一起使用,则可以正常android:verticalScrollbarPosition="left"
工作:android:scrollbarThumbVertical="@drawable/scrollbar_style"
ListView
它是一个错误吗?还是有另一种方法来操纵滚动条的样式和位置Spinner
?