我的 android 应用程序中有一个表格布局,想要第一列在右边,第二列在左边,我尝试使用 android:layoutDirection="rtl"但它只适用于 4.2 及更高版本, 在旧版本中,我可以使用什么来设置从右到左的方向。
我的xml文件是
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f5f5f5" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/barbac"
android:gravity="right" >
<ImageView
android:id="@+id/imgtit"
android:layout_width="60dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/noticetit"
android:layout_marginBottom="6dp"
android:layout_marginRight="5dp"
android:contentDescription="@string/app_name"
android:src="@drawable/ajeer_logo_trans2" />
<TextView
android:id="@+id/noticetit"
style="@style/textstl"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imgtit"
android:text="@string/worknotice" />
</RelativeLayout>
<TableLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="60dp"
android:layoutDirection="rtl"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_weight="1"
>
<TextView
android:id="@+id/laborname"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/laborname"
/>
<TextView
android:id="@+id/Vlaborname"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/iqamanum"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/iqamanum" />
<TextView
android:id="@+id/Viqamanum"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/instname1"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/instname1" />
<TextView
android:id="@+id/Vinstname1"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" >
</TextView>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/instnum"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/instnum" />
<TextView
android:id="@+id/Vinstnum"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/instactive"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/instactive" />
<TextView
android:id="@+id/Vinstactive"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/instname2"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/instname2" />
<TextView
android:id="@+id/Vinstname2"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/instnum2"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/instnum2" />
<TextView
android:id="@+id/Vinstnum2"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/sdate"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/sdate" />
<TextView
android:id="@+id/Vsdate"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/edate"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="@string/edate" />
<TextView
android:id="@+id/Vedate"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/lacation"
style="@style/noticform"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/location" />
<TextView
android:id="@+id/Vlocation"
style="@style/noticformstl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginBottom="80dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/roundrectangle" >
<TextView
android:id="@+id/expdate"
style="@style/expdatestl"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="30dp"
android:layout_marginTop="9dp"
android:layout_weight="1"
android:text="@string/expdate" />
<TextView
android:id="@+id/vexpdate"
style="@style/expdatestl1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:layout_weight="1" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/copyrights"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true"
android:text="@string/copyrights" />
</RelativeLayout>
提前致谢
最佳答案
LayoutDirection 是 API v17 中添加的新属性。
在此之前,此类任务是使用每个特定单元格的 gravity 或 layout_gravity 完成的。我不记得是哪一个了。
关于android - 早于 4.2 的 android 中从右到左的元素方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20535643/
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
查看我的Ruby代码:h=Hash.new([])h[0]=:word1h[1]=h[1]输出是:Hash={0=>:word1,1=>[:word2,:word3],2=>[:word2,:word3]}我希望有Hash={0=>:word1,1=>[:word2],2=>[:word3]}为什么要附加第二个哈希元素(数组)?如何将新数组元素附加到第三个哈希元素? 最佳答案 如果您提供单个值作为Hash.new的参数(例如Hash.new([]),完全相同的对象将用作每个缺失键的默认值。这就是您所拥有的,那是你不想要的。您可以改用
本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm
在Ruby中,是否有一种简单的方法可以将n维数组中的每个元素乘以一个数字?这样:[1,2,3,4,5].multiplied_by2==[2,4,6,8,10]和[[1,2,3],[1,2,3]].multiplied_by2==[[2,4,6],[2,4,6]]?(很明显,我编写了multiplied_by函数以区别于*,它似乎连接了数组的多个副本,不幸的是这不是我需要的)。谢谢! 最佳答案 它的长格式等价物是:[1,2,3,4,5].collect{|n|n*2}其实并没有那么复杂。你总是可以使你的multiply_by方法:c
给定两个大小相等的数组,如何找到不考虑位置的匹配元素的数量?例如:[0,0,5]和[0,5,5]将返回2的匹配项,因为有一个0和一个5共同;[1,0,0,3]和[0,0,1,4]将返回3的匹配项,因为0有两场,1有一场;[1,2,2,3]和[1,2,3,4]将返回3的匹配项。我尝试了很多想法,但它们都变得相当粗糙和令人费解。我猜想有一些不错的Ruby习惯用法,或者可能是一个正则表达式,可以很好地回答这个解决方案。 最佳答案 您可以使用count完成它:a.count{|e|index=b.index(e)andb.delete_at
我在尝试使用Nokogiri构建XML文档时遇到了一个小问题。我想将我的元素之一称为“文本”(请参阅下面粘贴代码的最底部)。通常,要创建一个新元素,我会执行类似以下的操作xml.text--但它似乎是.text是Nokogiri已经用来做其他事情的方法。因此,当我写这行时xml.textNokogiri没有创建名为的新元素但只是写了意味着成为元素内容的文本。我怎样才能让Nokogiri实际制作一个名为的元素??builder=Nokogiri::XML::Builder.newdo|xml|xml.TEI("xmlns"=>"http://www.tei-c.org/ns/1.0"
如果我想使用“create”构建策略创建和实例,然后想使用“attributes_for”构建策略进行验证,是否可以这样做?如果我在工厂中使用序列?在Machinistgem中有可能吗? 最佳答案 不太确定我是否完全理解。而且我不是机械师的用户。但听起来您只是想做这样的事情。@attributes=FactoryGirl.attributes_for(:my_object)my_object=MyObject.create(@attributes)my_object.some_property.should==@attributes
我想通过内部数组中的第一个元素从数组数组中找到唯一元素。例如a=[[1,2],[2,3],[1,5]我想要类似的东西[[1,2],[2,3]] 最佳答案 uniq方法需要一个block:uniq_a=a.uniq(&:first)或者如果您想就地进行:a.uniq!(&:first)例如:>>a=[[1,2],[2,3],[1,5]]=>[[1,2],[2,3],[1,5]]>>a.uniq(&:first)=>[[1,2],[2,3]]>>a=>[[1,2],[2,3],[1,5]]或者>>a=[[1,2],[2,3],[1,5]