转载自: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. discuz 系列产品 在ie9下注册成功后不跳转bug处理

    header.htm 把 <meta http-equiv="x-ua-compatible" content="ie=7" /> 改为 <m ...

  2. [转载]Matrix类的使用

    2013-12-18 11:31:00 转载自: http://www.cnblogs.com/mmy0925/archive/2013/01/22/2871009.html 在Android中,对图 ...

  3. 基于MVC模式的应用框架之struts

    1.struts开发步骤 引入struts的jar包: 在web.xml中引入struts的核心功能,配置struts核心过滤器:(如果项目中用到了其他过滤器,要放在struts过滤器之前,否则会失效 ...

  4. C#常用实例

    1 時間 1.1 顯示在走的時間 控件:TextBox為顯示日期時間,命名為txtDateTimer Timer為時鐘,命名為time private void dtDateTimer_Tick(ob ...

  5. 图解傅里叶变换(so easy)

    话不多说先上两个GIF图. 第一个动画和第二个动画其实都是对时域的周期矩形形波(近似看成矩形波,并不是严格意义的矩形方波)进行傅里叶变换分析. 对于第一个图形来说,它侧重展示变换的本质之一:叠加性,每 ...

  6. C# 调用配置文件SQL语句 真2B!

    /********************************************************************************* ** File Name : SQ ...

  7. 数组的foreach方法和jQuery中的each方法

    /* * 数组的forEach方法: * 1.返回给回调的参数先是值,然后是下标 * 2.回调函数执行时内部的this指向window * */ /*var arr = [1,2,3,4,5]; ar ...

  8. PHP ceil() 函数

    定义和用法 ceil() 函数向上舍入为最接近的整数. 语法 ceil(x) 参数 描述 x 必需.一个数. 说明 返回不小于 x 的下一个整数,x 如果有小数部分则进一位.ceil() 返回的类型仍 ...

  9. js 弹出div窗口 可移动 可关闭 (转)

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

  10. 求一个数组中最小的K个数

    方法1:先对数组进行排序,然后遍历前K个数,此时时间复杂度为O(nlgn); 方法2:维护一个容量为K的最大堆(<算法导论>第6章),然后从第K+1个元素开始遍历,和堆中的最大元素比较,如 ...