微调的滚动条风格 [英] Spinner's scrollbar style

查看:140
本文介绍了微调的滚动条风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着改变风格,这是一个微调的内部滚动条的位置,但它不能正常工作。

I've tried to change the style and the position of the scrollbar which is inside a spinner, but it does not work.

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);
    }
}

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>

绘制/ scrollbar_style.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>

值/ strings.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>

的Andr​​oidManifest.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>

截图:

注意安卓verticalScrollbarPosition =左安卓scrollbarThumbVertical =@可绘制/ scrollbar_style作品很好,如果我使用它们以的ListView

Note that android:verticalScrollbarPosition="left" and android:scrollbarThumbVertical="@drawable/scrollbar_style" works fine if I use them with a ListView:

是不是一个错误?或者有另一种方式来处理内部的滚动条的风格和位置微调

Is it a bug? or is there another way to manipulate the scrollbar style and position within a Spinner?

推荐答案

在Android的纱厂没有滚动条,滚动条保持了微调内部列表视图中存在,并且没有公共访问。

Spinners in Android doesn't have a Scrollbar, the scrollbar exist within the listView maintained inside the Spinner, and has no public access.

有一个运行时间的方式来覆盖它下面。

There's a run-time way to override it in the link below ..

来源: http://stackoverflow.com/a/12644532/2128327

这篇关于微调的滚动条风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆