【问题标题】:problems with custom spinner width自定义微调器宽度的问题
【发布时间】:2012-07-11 21:11:29
【问题描述】:

我正在尝试使我的应用程序右侧的编辑文本和微调器对齐并且大小相同,但我似乎无法更改微调器的宽度。我已经弄清楚如何更改微调器中单词中显示的字符数量,但我不知道如何更改实际微调器的大小。有什么建议么?这是我的微调器布局的 xml:

spinner_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title_text_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:maxLength="15" />

这就是我在我的活动中调用它的方式:

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,R.layout.spinner_layout,actions);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);

【问题讨论】:

    标签: android width spinner


    【解决方案1】:

    将您的 layout_width 和 layout_height 更改为“wrap_content”。那么它会改变。

    代码:

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/title_text_view"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:gravity="center" />
    

    【讨论】:

    • @user1424489 如果以下代码解决了您的问题,则表示接受答案.....
    【解决方案2】:

    尝试将代码更改为,它可能会对您有所帮助。

     ArrayAdapter NoCoreAdapter =  new ArrayAdapter(this,android.R.layout.simple_spinner_item,  month);
    

    【讨论】:

    • 尝试将(this,R.layout....)替换成(this,android.R.layout.simple_spinner_item,....)
    • 这里用文本实际内容设置微调器宽度。请尝试。
    猜你喜欢
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多