我看到了这个链接:
Assign width to half available screen width declaratively
如何在相对布局中做同样的事情? 这是代码:在相对布局中尝试线性布局。但这不起作用。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:text="UID"
android:textColor="#ffe5f1f1" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffe5f1f1"
android:hint="Enter UID"
android:inputType="number"
android:shadowColor="5"
android:textColor="#ff009999"
android:textStyle="bold"
android:typeface="monospace" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentLeft="true"
android:layout_marginTop="18dp"
android:text="Button" />
<Button
android:id="@+id/button8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button7"
android:layout_weight="1"
android:layout_marginTop="16dp"
android:text="Button" />
<Button
android:id="@+id/button9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button8"
android:layout_marginTop="17dp"
android:text="Button" />
<EditText
android:id="@+id/editText2"
android:layout_width="50"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:background="#ffe5f1f1"
android:ems="10"
android:hint="Enter Name"
android:inputType="number"
android:inputType="textPersonName"
android:textColor="#ff009999"
android:textStyle="bold"
android:layout_weight="1"
android:typeface="monospace" />
<EditText
android:id="@+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ems="10"
android:layout_weight="1"
android:inputType="number" />
<EditText
android:id="@+id/editText4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button7"
android:layout_alignBottom="@+id/button7"
android:layout_alignParentRight="true"
android:ems="10"
android:layout_weight="1"
android:inputType="phone" />
<EditText
android:id="@+id/editText5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button8"
android:layout_alignBottom="@+id/button8"
android:layout_alignParentRight="true"
android:ems="10"
android:layout_weight="1"
android:inputType="textPersonName" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button9"
android:layout_alignBottom="@+id/button9"
android:layout_alignLeft="@+id/editText5"
android:layout_weight="1"
android:text="Male" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/radioButton2"
android:layout_alignBottom="@+id/radioButton2"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:text="Female" />
<Button
android:id="@+id/button10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button9"
android:layout_marginTop="31dp"
android:layout_weight="1"
android:text="Button" />
<Spinner
android:id="@+id/spinDept"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button10"
android:layout_alignBottom="@+id/button10"
android:layout_alignLeft="@+id/radioButton2"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:background="#ff009999" />
</LinearLayout>
</RelativeLayout>
最佳答案
如果您在使用 RelativeLayout 时正好需要一半,这是一个很好的解决方法。你要做的是,制作一个假的不可见 View ,以父 View 为中心,并让左按钮与该假 View 对齐 alignParentLeft 和 alignRight ,右按钮反之亦然
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:id="@+id/fakeView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/fakeView"
android:layout_alignParentLeft="true"
android:text="Left"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/fakeView"
android:layout_alignParentRight="true"
android:text="Right"/>
</RelativeLayout>
它真的很聪明。
关于android - 调整宽度为半屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11244326/
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
使用Ruby,我必须将字符串以柱状格式输出到终端。像这样:|row1|astringhere|etc|row2|anotherstring|etc我可以使用String#ljust和%s处理拉丁UTF8字符。但是当字符是韩文、中文等时就会出现问题。当英文行与包含韩文等的行交错时,列根本不会对齐。如何在此处实现列对齐?有没有办法以等同于固定宽度字体的方式输出亚洲字符?对于要在Vim中显示和编辑的文档怎么样? 最佳答案 您的问题发生在CJK(中文/日文/韩文)full-widthandwidecharacters(也向下滚动图表);这些
所以我期待一系列不同尺寸和纵横比的照片。我希望能够缩小/拉伸(stretch)照片以尽可能适合200x100矩形,然后裁剪不适合的其余部分。我希望裁剪也发生在中心周围。这可能吗?我对imagemagick文档感到很困惑。谢谢! 最佳答案 Paperclip的#选项将完全满足您的需求:在指定尺寸内最大程度地适应图像,然后在中心处利用重力裁剪多余部分。例子:has_attached_file:photo,:styles=>{:original=>"200x100#"}注意:如果您想保持原样不变并生成额外的裁剪缩略图,只需将:origin
String.length只会告诉我字符串中有多少个字符。(其实在Ruby1.9之前,它只会告诉我多少个字节,这就更没用了。)我真的很想知道一个字符串有多少个“en”宽。例如:'foo'.width#=>3'moo'.width#=>3.5#m's,w's,etc.arewide'foi'.width#=>2.5#i's,j's,etc.arenarrow'foobar'.width#=>6.25#spacesareverynarrow如果我能得到字符串的第一个n就更好了:'foo'[0,2.en]#=>"fo"'filial'[0,3.en]#=>"fili"'foobarbaz'[
我刚刚经历了这个概念Zero-WidthAssertions从文档中。我想到了一些快速的问题-为什么这样的名字Zero-WidthAssertions?Look-ahead怎么了和look-behind概念支持这样的Zero-WidthAssertions概念?什么这样的?,,=s,-4个符号在模式内指示?你能帮我集中精力了解实际发生的事情我还尝试了一些小代码来理解逻辑,但对它们的输出没有那么自信:irb(main):001:0>"foresight".sub(/(?!s)ight/,'ee')=>"foresee"irb(main):002:0>"foresight".sub(/(?
运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid
1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La
编辑:褪色灰色仅是0.9.7.3及之前版本的问题。它后来变成了深灰色。Pry具有很好的着色效果,但创建或更改对象时返回的值是我几乎看不到的褪色灰色。u=User.new=>#我尝试修改.pryrc中的值,但无法更改此颜色或与此相关的任何其他颜色。 最佳答案 Pry使用CodeRay进行着色,因此您可以将以下内容放入您的.pryrc文件中:CodeRay.scan("example",:ruby).term#justtoloadnecessaryfilesTERM_TOKEN_COLORS={:symbol=>'1;31'#willm
Ai-Bot基于流行的Node.js和JavaScript语言的一款新自动化框架,支持Windows和Android自动化。1、Windowsxpath元素定位算法支持支持Windows应用、.NET、WPF、Qt、Java和Electron客户端程序和ie、edgechrome浏览器2、Android支持原生APP和H5界面,元素定位速度是appium十倍,无线远程自动化操作多台安卓设备3、基于opencv图色算法,支持找图和多点找色,1080*2340全分辨率找图50MS以内4、内置免费OCR人工智能技术,无限制获取图片文字和找字功能。5、框架协议开源,除官方node.jsSDK外,用户可
前一段时间由于工作需要把可爱的小雪狐舍弃了,找到了小蜜蜂。但是新版本的小蜜蜂出现了很多和旧版本不一样的位置。1.功能位置迁移,原来在工程build.gradle的buildscript和allprojects移动至setting.gradle并改名为pluginManagement和dependencyResolutionManagement。里面的东西依旧可以按照原来的copy过来。pluginManagement{repositories{gradlePluginPortal()google()mavenCentral()}}dependencyResolutionManagement{r