首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >移除旋转器中的间距

移除旋转器中的间距
EN

Stack Overflow用户
提问于 2018-10-23 17:01:45
回答 2查看 637关注 0票数 1

我想让文本与图片中的编辑文本保持一致。但是,耳聋旋转器也包括这种间距。因此,我想删除它使文本与左对齐。有人知道怎么修吗?

图片

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-23 17:23:46

创建布局名称spinner_text.xml。将此代码粘贴到其中:

代码语言:javascript
运行
复制
<TextView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textStart"
android:gravity="start"
android:maxLines="1"
/>

然后编辑您的java代码。像这样更改Java适配器。

代码语言:javascript
运行
复制
ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivity.this,
            R.layout.spinner_text,paths);

(按上述方式更改布局)。

然后旋转文本将与文本对齐。祝你好运。

票数 1
EN

Stack Overflow用户

发布于 2019-11-17 05:02:55

只需在xml旋转器布局中添加一些额外的减幅即可。不需要创建自定义文本视图布局。

如下所示:

代码语言:javascript
运行
复制
<Spinner
    android:id="@+id/spinnerDistrict"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="-6dp"
    android:layout_marginBottom="@dimen/basic_margin_padding_min"
    android:layout_marginTop="@dimen/basic_margin_padding_min"
    android:spinnerMode="dropdown" />

就这样!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52954320

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档