LinearLayout布局时使用右对齐android:layout_gravity="right")控件对齐方式不生效,需要设置 android:layout_weight="1" 才能右对齐控件,原因在于后者把位置平分了。

<LinearLayout android:gravity="right" android:layout_margin="2dip"
android:orientation="horizontal" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" > <Button android:id="@+id/btnCommonExpress" android:width="50dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:text="常用" />
<Button android:id="@+id/btnAll" android:width="50dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignRight="@+id/btnCommon"
android:text="所有" />
</LinearLayout>

[转]解决LinearLayout中控件不能居右对齐的更多相关文章

  1. 解决LinearLayout中控件不能居右对齐

    转载自:http://lgb168.blog.163.com/blog/static/49674438201172492935235/ 2011-08-24 21:35:25|  分类: Androi ...

  2. 48.UIButton上的字体居右对齐

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; button.titleLabel.textAlignment = NSTe ...

  3. c#中解决winform中控件不能输入汉字的办法

    设置控件的ImeMode属性 如:    textBox.ImeMode = System.Windows.Forms.ImeMode.On; 其中枚举有如下值:

  4. select使用css居右对齐

    select{ direction: rtl; } 下面的方法无效 select{ text-align: right; }

  5. form表单中控件较多,加载完成后切换页面都很慢的解决方法

    form表单中控件较多,加载完成后点击都很慢,为什么?我一页面中form表单里面上百个控件(如input.select.radio.checkbox等),还有一些js脚本,加载速度还可以,都能全部显示 ...

  6. 解决statusStrip控件上的项目不能靠右对齐的问题

    在c#中用到了状态栏控件StatusStrip,但当我想把StatusStrip上某个StatusLabel靠右对齐时出了问题. 按照MSDN中的办法,是设置ToolStripStatusLabel的 ...

  7. WPF Devexpress ChartControl CrosshairLabel显示内容居右

    源码可加Q群:580749909. 一.解决的问题 ChartControl中希望CrosshairLabel的内容据右 or 自定义 二.实现. 多个显示实例(实例:条形,线形,点等等)下的内容设置 ...

  8. Metro中控件WebView访问外部的网页显示一片空白

    Metro中控件WebView访问外部的网页显示一片空白 解决方案: ​下载安装了Initex.Software.Proxifier.v3.21.Standard.Edition.Incl.Keyma ...

  9. Android 中LinearLayout控件属性

    id             为控件指定相应的ID        text           指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符        g ...

随机推荐

  1. LeetCode OJ 53. Maximum Subarray

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  2. iOS 通过颜色来生成一个纯色图片

    //通过颜色来生成一个纯色图片- (UIImage *)buttonImageFromColor:(UIColor *)color{        CGRect rect = CGRectMake(0 ...

  3. 在 iOS 应用中直接跳转到 AppStore 的方法

      找到应用程序的描述链接,在itunes中找到相应的应用,(如下图),点击免费右边的下方向键,选择复制链接,就拿到了对应的app的描述链接 比如:https://itunes.apple.com/c ...

  4. jq的siblings对a标签不起效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. tomcat下同时部署两个项目不能正常启动的问题

    在部署两个项目,这两个项目都是采用了一个框架,只是业务系统进行了修改.部署的时候发现启动有问题.会报类似下边的错误 Web app root system property already set t ...

  6. mybatis 一点整理

    mapper指定对应的接口 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper ...

  7. perl 简单后门程序

    #!/usr/bin/env perl use warnings; use strict; use Socket; my $HOST='localhost'; ; socket(S,PF_INET,S ...

  8. jquery源码阅读(1)

    每天坚持阅读一定量的的jquery代码,积少成多!加油加油! jquery-2.2.1的9161~9194行 1 if ( typeof define === "function" ...

  9. 《Windows驱动开发技术详解》之分层驱动程序

    分层驱动程序概念 分层的目的是将功能复杂的驱动程序分解成多个简单的驱动程序.一般来说,他们是指两个或两个 以上的驱动程序,它们分别创建设备对象,并且形成一个由高到低的设备对象栈.IRP请求一般会被传送 ...

  10. Chapter 1 First Sight——35

    The final bell rang at last. I walked slowly to the office to return my paperwork. 最后下课铃响了.我走到了办公室上讲 ...