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

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(使用前将#替换为@)

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

  • 在 Android 8 (Oreo) 的 Webview 中获取 Resources$NotFoundException

    我正在我的应用程序的 WebView 中加载网站的 URL 该网站获取用户的基本详细信息 我正在活动中加载 WebView 但是 当 Android 8 用户点击网站的下拉菜单时 应用程序会抛出以下错误 请注意 此 WebView 在 An
  • Android - 如何创建可点击的列表视图?

    我想让列表视图中的所有列表项打开到一个新页面 因此每个列表视图项目都打开到一个我可以使用的新黑色页面 我根本不知道如何实现这个 我已经连续搜索了几个小时 但找不到解决方案的答案 如果有人能够展示和 或解释如何执行此操作而不是提供链接 我们将
  • 进入沉浸式全屏模式时状态栏为白色

    我根据以下内容做了一个关于沉浸式全屏模式的简单项目使用沉浸式全屏模式 https developer android com training system ui immersive html But first of all it per
  • Android ViewPager + 带有动态 ListView 的 Fragments

    在我的应用程序中 我有带有选项卡的活动 假设有 10 个选项卡 每个标签页包含Fragment with ListView 此 ListView 中显示的数据是从我的服务器动态加载的 我用ViewPager显示这些页面 我不想保留所有Fra
  • 安卓写入文件

    经过几周的不编程之后 我决定完成我的应用程序 上次我无法进行文件写入和读取 现在我想做 我也许可以使用数据库 但这似乎容易得多 我已经发现this http narenst wordpress com 2010 01 25 android
  • 导入的项目抛出 java.lang.ClassNotFoundException

    所以我将一个现有的项目导入到 eclipse 中 但让它工作时遇到了很多麻烦 该项目与其他三个图书馆项目一起提供 谷歌播放服务库 捕获活动 肖像二维码 As soon as I imported the project I went und
  • 创建像 facebook android 一样的登录动画

    我想创建一个登录页面 如 facebook android 应用程序 其中包含用户名和密码EditText字段被隐藏 页面上会显示一个徽标 该徽标会在上方动画一定距离并停留在新位置 然后显示编辑字段 这是我尝试过的 但这里的徽标从页面底部开
  • ListView 可以存储多少个项目?

    我是 Android 编程新手 我想知道ListView可以存储多少个项目 我在文档中搜索 但他们没有谈论这个 如果我将很多 可能是 10k 项放入 ListAdapter 中 会影响性能吗 干杯 MK ListView 在 Android
  • 自定义 listView 按随机顺序显示较少的项目

    我为我的 Android 应用程序制作了一个自定义的膨胀 listView 但 getView 方法有问题 public class BinderData extends BaseAdapter private LayoutInflater
  • Motorola Android 2.2 相机忽略 EXTRA_OUTPUT 参数

    我以编程方式打开相机来拍摄视频 我告诉相机使用如下代码将视频文件放置到指定位置 Intent intent new Intent MediaStore ACTION VIDEO CAPTURE File out new File sdcar
  • 制作教程(教练标记)叠加层。需要帮助根据另一个视图的位置移动视图

    你好 我正在尝试在教程上做一个教练标记 主程序 java public class Main extends Activity private Button button1 private int x Override public voi
  • adb 无法启动守护进程,CreateProcess 失败,错误 2

    我无法运行adb root或任何 adb 命令 我收到以下错误 我设置ADB TRACE 1 C WINDOWS system32 gt adb root system core adb adb c main Handling comman
  • HttpURLConnection.getResponseCode() 冻结执行/不会超时

    我正在编写一个 Android 应用程序 它连接到受密码保护的 cPanel 服务器 Apache 2 2 22 页面 当身份验证凭据正确时 我的连接没有问题 但是 当凭据不正确时 我的 Android 应用程序似乎会冻结在HttpURLC
  • 三星 Galaxy Note 上的布局

    我有一个奇怪的问题 只出现在 Samsung Galaxy Note 上 我有横向和纵向布局 正常和大 如下 http developer android com guide practices screens support html h
  • Android sqlite 缺少列

    我的 SQLite 数据库缺少一个我知道存在的列 我将无法从 Android 模拟器中提取数据库 因为如果不重写大量代码 就无法使用模拟器填充数据库 logcat 返回sqlite returned error code 1 msg tab
  • org.apache.http 软件包在 API 级别 23 中被删除。替代方案是什么?

    在更新到最新的 android API 级别 23 Marshmallow 后 通过 build gradle 添加以下更改后 所有 org apache http 类都不起作用 android compileSdkVersion 23 b
  • FirebaseAuth.getInstance().signOut() 不注销

    我尝试从 firebase 注销用户 但在关闭应用程序并再次打开后 用户仍然处于连接状态 我尝试从 firebase 定期注销用户 但没有解决问题 我想知道是什么导致了这个问题 logout setOnClickListener new V
  • 如何使用 Android 手机通话时播放声音?

    是否可以通过编程方式与电话进行交互 例如 您可以通过程序向呼叫者播放音频吗 Google 尚未公开任何允许我们向特定正在进行的调用提供数据的 API 不过 您可以控制通话 检查这篇文章 here http prasanta paul blo
  • 在 Android 中创建硬链接和符号链接

    我正在创建一个应用程序 我想在其中使用 Android 外部内存文件系统中的硬链接和符号链接 我尝试过使用命令 Os link oldpath newpath Os link oldpath newpath 但是 当我尝试这样做时 我收到此
  • Android:警报对话框消失并执行下一个意图

    我正在使用禁用 GPS 的 AlertDialog 一旦用户启用 GPS 我就会通过 Intent 转到另一个 Activity 问题是 AlertDialog 出现 然后移动到下一个活动 然后我才能单击对话框上的任何按钮 我需要做什么才能

随机推荐

  • 使用 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 代码