如何将旋转器从右向左对齐?

2024-05-16

谁能告诉我我做错了什么? :( 我有 2 个 Spinner 和两个 TextView,我想将它们右对齐。 我已将所有内容设置为右侧,但所有内容仍然左对齐。

它是这样的:

但我也希望它看起来像这样:

这是我的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" 
android:layout_gravity="right"
android:gravity="right">
    <RadioGroup
        android:id="@+id/radios"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:gravity="center_horizontal"
        android:inputType="text"
        android:onClick="test"
        android:orientation="horizontal"
        android:paddingRight="10dp" >

        <RadioButton
            android:id="@+id/rbtn_sell"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:button="@null"
            android:drawablePadding="3dp"
            android:drawableRight="@android:drawable/btn_radio"
            android:text="@string/label_sell_unicode"
            android:textSize="12sp" />

        <RadioButton
            android:id="@+id/rbtn_rent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:button="@null"
            android:drawablePadding="3dp"
            android:drawableRight="@android:drawable/btn_radio"
            android:text="@string/label_rent_unicode"
            android:textSize="12sp" 
            android:paddingLeft="40dp"/>
    </RadioGroup>
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_gravity="center"
    android:gravity="right"
    android:orientation="horizontal"
    >

    <TextView
        android:id="@+id/textView_from"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/label_from" 
        />
    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:drawable/btn_dropdown"
        android:gravity="right"
        android:layout_gravity="right"
        android:spinnerMode="dropdown" />
    <TextView
        android:id="@+id/textView_to"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/label_to" 
        />
    <Spinner
        android:id="@+id/spinner2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:drawable/btn_dropdown"
        android:gravity="right"
        android:layout_gravity="right"
        android:spinnerMode="dropdown" />



</LinearLayout>

更新:进行 ElDuderino 建议的更改后我的 XML。进行此更改后,两个 TextView 和两个 Spinner 消失了。他们不在屏幕上。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<RadioGroup
    android:id="@+id/radios"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:gravity="center_horizontal"
    android:inputType="text"
    android:onClick="test"
    android:orientation="horizontal"
    android:paddingRight="10dp" >

    <RadioButton
        android:id="@+id/rbtn_sell"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:button="@null"
        android:drawablePadding="3dp"
        android:drawableRight="@android:drawable/btn_radio"
        android:text="@string/label_sell_unicode"
        android:textSize="12sp" />

    <RadioButton
        android:id="@+id/rbtn_rent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@null"
        android:drawablePadding="3dp"
        android:drawableRight="@android:drawable/btn_radio"
        android:text="@string/label_rent_unicode"
        android:textSize="12sp" 
        android:paddingLeft="40dp"/>
</RadioGroup>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="2" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView_from"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="From" />

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:drawable/btn_dropdown"
            android:spinnerMode="dropdown" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView_to"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="To" />

        <Spinner
            android:id="@+id/spinner2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:drawable/btn_dropdown"
            android:spinnerMode="dropdown" />
    </LinearLayout>
</LinearLayout>
</LinearLayout>

您在单选按钮上添加可绘制对象时犯了一个错误。试试这个,让我知道

android:drawableLeft="@android:drawable/btn_radio"

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将旋转器从右向左对齐? 的相关文章

  • 如何对这个字符串进行子串化

    我想得到这个字符串的 4 个部分 String string 10 trillion 896 billion 45 million 56873 我需要的4个部分是 10万亿 8960亿 4500万 和 56873 我所做的是删除所有空格 然
  • 如何在 Android 中保存相机的临时照片?

    在尝试从相机拍照并将其保存到应用程序的缓存文件夹中时 我没有得到任何可见的结果 应用程序不会崩溃 但在 LogCat 上 当我尝试将 ImageView src 字段设置为刚刚获取的文件的 URI 时 我收到此消息 09 17 14 03
  • 类型容器“Android 依赖项”引用不存在的库 android-support-v7-appcompat/bin/android-support-v7-appcompat.jar

    我在尝试在我的项目中使用 Action Bar Compat 支持库时遇到了某种错误 我不知道出了什么问题 因为我已按照此链接中的说明进行操作 gt http developer android com tools support libr
  • 在 Android Studio 中,为什么我必须在模拟器中单击“运行应用程序”两次才能启动应用程序?

    在 Android Studio 中 当我按播放按钮在 Android 模拟器上安装并运行应用程序时 大约 5 10 秒后 我在屏幕底部收到一条消息 显示 安装成功 但应用程序实际上并未运行在模拟器上 我必须再次按下播放按钮 这是非常令人沮
  • Android 后退按钮无法与 Flutter 选项卡内的导航器配合使用

    我需要在每个选项卡内有一个导航器 因此当我推送新的小部件时 选项卡栏会保留在屏幕上 代码运行得很好 但是 android 后退按钮正在关闭应用程序而不是运行 Navigator pop import package flutter mate
  • CardView 圆角获得意想不到的白色

    When using rounded corner in CardView shows a white border in rounded area which is mostly visible in dark environment F
  • 无法获取log.d或输出Robolectrict + gradle

    有没有人能够将 System out 或 Log d 跟踪从 robolectric 测试输出到 gradle 控制台 我在用Robolectric Gradle 测试插件 https github com robolectric robo
  • 如何以编程方式检查 AndroidManifest.xml 中是否声明了服务?

    我正在编写一个库 该库提供了一项服务 其他开发人员可以通过将其包含在他们的项目中来使用该服务 因此 我无法控制 AndroidManifest xml 我在文档中解释了要做什么 但一个常见的问题是人们忽略了将适当的 标记添加到其清单中 或者
  • java.lang.NoClassDefFoundError:org.apache.batik.dom.svg.SVGDOMImplementation

    我在链接到我的 Android LibGDX 项目的 Apache Batik 库时遇到了奇怪的问题 但让我们从头开始 在 IntelliJ Idea 中我有一个项目 其中包含三个模块 Main Android 和 Desktop 我强调的
  • Android SIP 来电使用带有广播接收器的服务

    大家好 其实我正在尝试创建一个应用程序 支持基于 SIP 通过互联网进行音频呼叫 这里使用本机 sip 我遇到了来电问题 我已经完成了服务的注册部分 但是在接听电话时我无法接听电话 请帮助我 Service file package exa
  • 尝试将相机切换回前面但出现异常

    尝试将相机切换回前面 但出现异常 找不到 问题请检查并帮助 error 01 27 11 49 00 376 E AndroidRuntime 30767 java lang RuntimeException Unable to start
  • 无法展开 RemoteViews - 错误通知

    最近 我收到越来越多的用户收到 RemoteServiceException 错误的报告 我每次给出的堆栈跟踪如下 android app RemoteServiceException Bad notification posted fro
  • 如何使用 IF 检查 TextView 可见性

    我有一个 onCheckedChangeListener 来根据选择的单选按钮显示文本视图 我有 1 个疑问和 1 个难题 想知道是否有人可以帮助我 问题 您能否将单选组默认检查值设置为 否 单选按钮 以便一开始就不会检查任何内容 问题 如
  • Android Studio 0.4.3 Eclipse项目没有gradle

    在此版本之前 在 Android Studio 中按原样打开 Eclipse 项目似乎很容易 无需任何转换 我更喜欢 Android Studio 环境 但我正在开发一个使用 eclipse 作为主要 IDE 的项目 我不想只为这个项目下载
  • 字符串数组文本格式化

    我有这个字符串 String text Address 1 Street nr 45 Address 2 Street nr 67 Address 3 Street nr 56 n Phone number 000000000 稍后将被使用
  • Android访问远程SQL数据库

    我可以直接从 Android 程序访问远程 SQL 数据库 在网络服务器上 吗 即简单地打开包含所有必需参数的连接 然后执行 SQL 查询 这是一个私人程序 不对公众开放 仅在指定的手机上可用 因此我不担心第三方获得数据库访问权限 如果是这
  • 在activity_main.xml中注释

    我是安卓新手 据我所知 XML 中的注释与 HTML 中的注释相同 使用 形式 我想在 Android 项目的 Activity main xml 配置文件中写一些注释 但它给了我错误 值得注意的是 我使用的是 Eclipse 但目前 我直
  • 如何确定对手机号码的呼叫是本地呼叫还是 STD 或 ISD

    我正在为 Android 开发某种应用程序 但不知道如何获取被叫号码是本地或 STD 的号码的数据 即手机号码检查器等应用程序从哪里获取数据 注意 我说的是手机号码 而不是固定电话 固定电话号码 你得到的数字是字符串类型 因此 您可以获取号
  • 捕获的图像分辨率太大

    我在做什么 我允许用户捕获图像 将其存储到 SD 卡中并上传到服务器 但捕获图像的分辨率为宽度 4608 像素和高度 2592 像素 现在我想要什么 如何在不影响质量的情况下获得小分辨率图像 例如我可以获取或设置捕获的图像分辨率为原始图像分
  • Crashlytics 出现 Android Studio 构建错误

    我正在尝试将 CrashLytics 与 Android Studio 和 gradle 一起使用 但出现一个令人困惑的错误 java lang NoSuchMethodError 我的 build gradle 是 buildscript

随机推荐

  • 使用 BitBlt 捕获程序窗口始终返回相同的图像

    我编写了以下代码 C Win32 来捕获游戏窗口屏幕并从图像中获取像素颜色数组 函数 autoB 完成这项工作 然后我将结果数组绘制到窗口中以直观地检查我得到的结果 问题是 这个程序在我启动计算机后只工作一次 在第一次 缓存 从游戏中获取的
  • 控制缓存过期

    通过 Google 网站管理员工具的 PageSpeed 分析器运行我的网页后 它向我报告我的资源没有被缓存 下面是我的 htaccess 文件中直接取自 H5BP 的代码 我是否正确地假设以下过期时间设置正确 但我的实现中出现了问题 或者
  • axios post请求react-native中出现网络错误

    这是我通过 axios post 请求检查身份验证的方法 CheckAuth let obj username email protected cdn cgi l email protection password zzxxz oauth
  • 我的 Powershell GUI 界面在打开网格视图时不断调整大小

    我目前正在构建一个复制到剪贴板工具 其中显示存储在文件夹中的 txt 文件列表 并且我使用 out gridview 来允许用户更好地选择和过滤列表 我已附上图片以供参考 单击加载 out gridview 的按钮后如何停止调整大小 Too
  • Spring Thymeleaf - 调用服务方法布尔值来显示 HTML 项目

    在我的标题 HTML 中 我显示一个 UL LI 菜单 其中 LI 项目之一的可见性取决于服务方法调用 我试过这个 家庭控制器 Controller public class HomeController private static fi
  • (Tcl/Expect) 退出后清屏

    我想在退出我的 半 交互式期望脚本后清除屏幕 在本地计算机上 我可以在脚本中做到这一点吗 这是我尝试过的 但失败了 usr bin expect f set env TERM vt100 spawn ssh Y username domai
  • Jquery $(window).width() 不包括滚动条宽度?

    我有一个页面使用 javascript 设置了很多 css 属性 并使用 window width 来确定页面宽度 除此之外 它还使用该方法将一些 div 宽度设置为页面的完整宽度 A 这样做是因为很多其他计算都是在 javascript
  • 如何检查带有通配符的模拟调用?

    我正在编写单元测试 并且想要检查具有函数对象的调用 如下所示 call u mock u foobar
  • 如何在 Rails 4 中使用 params.require

    我有一个像这样的私有方法 用于有四个字段的注册表单 firstname email password and confirm password 我不知道如何检查password confirmation def user params pa
  • Godaddy 托管上的 CakePHP 控制台

    我一直在努力让我的 CakePHP 网站在 Godaddy 网格托管 帐户上运行 我的蛋糕应用程序设置是从帐户的子目录托管的 并且可以通过子域访问 我必须调整我的 htaccess 文件才能使其正常工作 现在我需要让 CakePHP 控制台
  • 如何从连接矩阵绘制图像?

    我想编写一个脚本来从连接矩阵创建图像 基本上 只要矩阵中有 1 我就希望该区域在图像中被着色 对于例如 我使用 Photoshop 创建了这张图像 但我有一个很大的数据集 所以我必须自动化这个过程 如果有人能指出我正确的方向 那将非常有帮助
  • 解析日期不正确

    My code DateFormat format new SimpleDateFormat dd MM YYYY Date Today format parse today Date Date format parse date diff
  • 创建 AoT 兼容的服务工厂

    我正在尝试为缓存服务创建一个服务工厂 主要要求是每次可以使用不同的字符串实例化单个服务 最终的结果会有多个cache每个服务都由唯一定义databaseName 每个缓存可以有一个或多个stores也由唯一定义storeName 其他服务将
  • caffe reshape / 上采样全连接层

    假设我们有一个像这样的层 layer name fully connected type InnerProduct bottom bottom top top inner product param num output 1 输出是batc
  • ES2015 中 `export { foo as default }` 有效吗?

    我收到了GitHub 上的问题 https github com benmosher eslint plugin import issues 54关于我的 ES2015 模块导入 导出验证插件 ESLint 无法识别default使用以下语
  • 左值引用和右值引用之间的重载解析

    include
  • 如何通过Android应用程序将数据发送到蓝牙打印机?

    我正在开发一个应用程序 它将通过蓝牙将数据发送到打印机进行打印 收据热敏打印机 我已按照此链接中的代码进行操作 http pastie org 6203514 http pastie org 6203514这个链接也http pastie
  • Cloud Firestore 安全规则 - 文档中的单个受保护字段

    我想要一个名为的只读属性suspendedProfile in a user具有当前登录用户的读 写访问权限的所有其他属性的文档 有没有办法通过简单的安全规则来做到这一点 我想到了2个解决方案 禁止修改属性的写入 例如allow write
  • 获取 GitHub 问题的管道价值?

    我使用 ZenHub 来管理 GitHub 上的问题 当我查看问题的详细信息时 我可以在 GitHub 中看到属性 pipeline 这正是保存问题的列 Now I want to get the pipeline information
  • 如何将旋转器从右向左对齐?

    谁能告诉我我做错了什么 我有 2 个 Spinner 和两个 TextView 我想将它们右对齐 我已将所有内容设置为右侧 但所有内容仍然左对齐 它是这样的 但我也希望它看起来像这样 这是我的 XML 代码