jjzjj

安卓/微调器 : Remove padding to the right of the arrow

coder 2023-12-20 原文

我在相对布局中使用微调器和几个其他布局元素 (layout-v21):

<Spinner
android:id="@+id/spinner"
android:layout_width="155dp"
android:layout_height="34dp"
android:layout_alignBottom="@+id/textList"
android:layout_alignTop="@+id/textList"
android:layout_alignParentEnd="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="0dp"
android:layout_toEndOf="@+id/textList"
android:paddingRight="1dp"/>

这会设置到父布局结束位置的距离:

android:layout_marginRight="0dp"
android:layout_alignParentEnd="true"

这设置了微调器中的选择项可以有多接近箭头的左侧(文本的右填充):

android:paddingRight="1dp"

但是有没有一种方法可以消除(或至少缩小)箭头右侧但仍在微调器布局元素内的不必要的空间/填充(这样我就可以然后在左侧使用更多空间而不改变微调器的大小)?

这就是我要说的:

编辑:这是 RelativeLayout 的代码:

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.mycompany.myapp.MainActivity"
android:backgroundTint="#000000"
android:focusableInTouchMode="true">

最佳答案

它对我有用:

<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:backgroundTint="#000000"
android:focusableInTouchMode="true">

    <Spinner
        android:id="@+id/spinner"
        android:layout_width="155dp"
        android:layout_height="34dp"
        style="@style/spinner_style"
        android:layout_alignParentEnd="true"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="0dp"
        android:paddingRight="1dp"/>

样式.xml

 <style name="spinner_style">
        <item name="android:layout_height">35dp</item>
        <item name="android:background">@drawable/spinner_bg</item>
</style>

微调器_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <layer-list>
            <item>
                <shape>
                    <gradient android:angle="90" android:endColor="@android:color/white" android:startColor="@android:color/white" android:type="linear" />

                    <stroke android:width="1dp" android:color="@color/colorAccent" />

                    <corners android:radius="0dp" />

                    <padding android:bottom="6dp" android:left="6dp" android:right="6dp" android:top="6dp" />
                </shape>
            </item>
            <item>
                <bitmap android:gravity="center|right" android:src="@drawable/ic_spin_down_arrow" />
            </item>
        </layer-list>
    </item>

</selector>

关于安卓/微调器 : Remove padding to the right of the arrow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50236588/

有关安卓/微调器 : Remove padding to the right of the arrow的更多相关文章

  1. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  2. (一)专题介绍:移动端安卓手机改造成linux服务器&linux服务器中安装软件、部署前后端分离项目实战 - 2

    快捷目录前言一、涉及到的相关技术简介二、具体实现过程及踩坑杂谈1.安卓手机改造成linux系统实现方案2.改造后的手机Linux中软件的安装3.手机Linux中安装MySQL5.7踩坑实录4.手机Linux中安装软件的正确方法三、Linux服务器部署前后端分离项目流程1.前提准备(安装必要软件,搭建环境):2.前后端分离项目的详细部署过程:总结前言总体概述:本篇文章隶属于“手机改造服务器部署前后端分离项目”系列专栏,该专栏将分多个板块,每个板块独立成篇来详细记录:手机(安卓)改造成个人服务器(Linux)、Linux中安装软件、配置开发环境、部署JAVA+VUE+MySQL5.7前后端分离项目

  3. javascript - AngularJs 中带有微调器的甜蜜警报对话框 - 2

    我正在尝试在sweetalert对话框中显示一个微调器,类似于Bootstrap模态对话框(http://jsfiddle.net/D6rD6/5/)我能想到的最接近的是这样的:SweetAlert.swal({title:'Importerrorsoccurred!',text:'',html:true,customClass:'manual-upload-errors-swal-width'});如果这不可能,那么最接近和最好的解决方案是什么? 最佳答案 原版sweetalert插件不支持,建议使用SweetAlert2插件。迁

  4. javascript - 文件上传开始/完成时显示/隐藏微调器 - 2

    我正在使用thisReactcomponent将文件上传到浏览器(而不是服务器)。此组件是react-jsonschema-form的一部分库,所以我无法更改源代码。render该组件的方法如下所示render(){const{multiple,id,readonly,disabled,autofocus}=this.props;const{filesInfo}=this.state;return((this.inputRef=ref)}id={id}type="file"disabled={readonly||disabled}onChange={this.onChange}defa

  5. javascript - 如何设置 jQuery 微调器的最大值和最小值? - 2

    我遇到了下一个问题:我正在使用jQuery+ajax,我希望在从服务器获取数据后设置微调器的最大值和最小值。但实际情况是,当我用Firebug检查元素时,它说设置了最大值和最小值,但实际上它们没有设置,所以没有最大值和最小值。这是一些代码:......$("#spinId").attr('min',0.0);$("#spinId").attr('max',parseFloat($('.someClass').text()));...而这个.someClass是通过ajax形成的。我还注意到值设置正确,即$('#spinId').attr('value',ValueFromServer)

  6. javascript - 在 AJAX 请求期间显示微调器? - 2

    显示微调器的最佳方式是什么?我准备了一个div(id="spinner"),它应该在加载期间可见。 最佳答案 你使用jQuery吗?如果是这样你可以使用:ajaxStart和ajaxStop:http://docs.jquery.com/Ajax例如:$(function(){//hideitfirst$("#spinner").hide();//whenanajaxrequeststarts,showspinner$.ajaxStart(function(){$("#spinner").show();});//whenanajax

  7. javascript - 显示微调器,直到 iframe 加载了 http post 响应 - 2

    我有两个网站A.com和B.com。我必须将B.com嵌入到A.com的iframe中。我无法在B.com进行任何更改B.com仅适用于带有一些发布数据的发布请求。我的工作如下//Createiframevar$ifr=$('');//createformvar$form=$('');//AppendhiddenfieldtoformtopasspostData$form.append($('').val('data'));//Appendformtotheiframeandthenappendiframetothediv$('#frameDiv').append($ifr.appen

  8. javascript - 微调性能时,多次调用 JavaScript 方法的最佳方式是什么? - 2

    我一直在研究JavaScript的性能。我了解到,当访问不止一次时,通常最好将闭包变量和类成员复制到本地范围以加快速度。例如:vari=100;vardoSomething=function(){varlocalI=i;//dosomethingwithlocalIabunchoftimesvarobj={a:100};varobjA=obj.a;//dosomethingwithobjAabunchoftimes};我明白这一点;它为解释器添加了一个按名称查找值的快捷方式。在处理方法时,这个概念变得非常不清楚。起初,我认为它会以同样的方式工作。例如:varobj={fn:functi

  9. javascript - 如何使用 knockout.js 显示图像加载微调器 - 2

    我正在使用knockout来绑定(bind)图像列表。在加载图像时设置微调器背景的最佳方法是什么。我有一个微调器类,我可以设置和取消设置背景图像,但想知道是否有一种简单的方法可以使用knockout.js绑定(bind)到图像完成事件。 最佳答案 使用jqueryUI的小微调器,我有一个像这样的绑定(bind)处理程序ko.bindingHandlers.Loading={update:function(element,valueAccessor,allBindingsAccessor){varvalue=valueAccessor

  10. 微信小程序安卓视频播放卡顿问题 - 2

    在微信小程序开发中遇到在video组件的两个问题1.安卓手机里播放视频会有明显的卡顿问题刚开始以为是网络问题,或者是视频文件问题。排查了一下发现都没问题最后加了个属性就OK了uniapp和原生小程序方法:custom-cache="false"custom-cache={{false}}video组件兼容iOS手机custom-cache加了这个属性会让2.iOS手机第一次播放视频会有几秒黑屏问题因此我加了当前手机型号的判断uni.getDeviceInfo().deviceType获取当前设备api当为iPhone时不加custom-cache属性,否则加上custom-cache=“fal

随机推荐