转载自:http://lgb168.blog.163.com/blog/static/49674438201172492935235/

2011-08-24 21:35:25|  分类: Android |  标签:android  linearlayout  对齐  |举报|字号 订阅

 
 

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中控件不能居右对齐

    在LinearLayout布局时使用右对齐(android:layout_gravity="right")控件对齐方式不生效,需要设置 android:layout_weight= ...

  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. 解决statusStrip控件上的项目不能靠右对齐的问题

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

  6. LinearLayout中组件右对齐

    在LinearLayout中,如果将其定位方向设为横向排列:android:orientation="horizontal",那么这个布局中的控件将自左向右排列. 但有时会有这样的 ...

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

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

  8. pageControl设置不居中显示,居左或居右

    UIPageControl控件,默认是居中显示的,如下图: 在很多的APP中,会看到pageControl是居左或居右显示的,如下图:   如何控制pageControl的位置显示呢? 设置为居右的代 ...

  9. LinearLayout控件

    LinearLayout是线性布局控件,它包含的子控件将以横向或竖向的方式排列,按照相对位置来排列所有的widgets或者其他的containers,超过边界时,某些控件将缺失或消失.因此一个垂直列表 ...

随机推荐

  1. [转载]查看基于Android 系统单个进程内存、CPU使用情况的几种方法

    转载自: http://www.linuxidc.com/Linux/2011-11/47587.htm 一.利用Android API函数查看1.1 ActivityManager查看可用内存. A ...

  2. 增加JVM虚拟机内存,防止内存溢出

    JAVA_OPTS=-Xms512m -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -XX:MaxNewSize=256m

  3. Program L 暴力求解

    Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...

  4. 12-28 显示团购数据界面的搭建,cell的自定义方面的知识总结

    1.通过plist加载模型数据 2.controller中懒加载数据 3.设置tableView的数据源 4.写数据源的方法 5.观察演示项目,分析通过默认的cell的4种现实方式,无法实现要想要的现 ...

  5. Reachability判断网络是否连接

    类似于一个网络状况的探针. [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabili ...

  6. IOS之Core Foundation框架和Cocoa Foundation框架的区别

    Core Foundation框架 (CoreFoundation.framework) 是一组C语言接口,它们为iOS应用程序提供基本数据管理和服务功能.下面列举该框架支持进行管理的数据以及可提供的 ...

  7. iOS9的适配

    1.大部分社交平台接口不支持https协议. 问题描述:在iOS9下,系统默认会拦截对http协议接口的访问,因此无法获取http协议接口的数据.对ShareSDK来说,具体表现可能是,无法授权.分享 ...

  8. 走过路过不要错过~教你用java抓取网页中你想要的东东~~

    学习了正则之后,打算用java玩一玩,所以就决定用它来实现一个好玩的idea import java.io.BufferedReader; import java.io.IOException; im ...

  9. lower_bound和upper_bound算法

    参考:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html ForwardIter lower_bound(ForwardIte ...

  10. Android Priority Job Queue (Job Manager)(一)

     Android Priority Job Queue (Job Manager)(一) 一.为什么要引入Android Priority Job Queue (Job Manager)?如今的A ...