在上面的屏幕中,我有两个线性布局,一个用于两个 TextView 和两个 EditText,另一个布局用于三个按钮,如图所示,
现在我想将这两个布局设置如下:
1)第一个布局需要设置在屏幕中心
2) 所有按钮或第二布局必须设置在屏幕底部
所以我想问问我该怎么做。
我的 XML 文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000044">
<ScrollView android:id="@+id/scrollView1" android:layout_height="wrap_content" android:layout_width="match_parent">
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content" android:layout_gravity="center">
<TextView android:text="Login Phone" style="@style/TextStyle.Default" android:id="@+id/loginphone"></TextView>
<EditText android:layout_height="wrap_content" android:id="@+id/login" android:layout_width="match_parent" android:text="" android:inputType="number" android:numeric="integer" android:phoneNumber="true"></EditText>
<TextView android:text="Mobile Pin" android:id="@+id/mobilepin" style="@style/TextStyle.Default"></TextView>
<EditText android:layout_height="wrap_content" android:id="@+id/pin" android:inputType="number" android:numeric="integer" android:layout_width="match_parent" android:text="" android:password="true"></EditText>
</LinearLayout>
</ScrollView>
<LinearLayout android:id="@+id/linearLayout2" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_width="fill_parent" android:orientation="horizontal" android:gravity="bottom">
<Button android:id="@+id/preference" android:text="Preferences" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
<Button android:id="@+id/loginbutton" android:text="Login" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
<Button android:id="@+id/exit" android:text="Exit" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
</LinearLayout>
</LinearLayout>
最佳答案
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000044">
<ScrollView
android:id="@+id/scrollView1"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1">
<LinearLayout
android:id="@+id/linearLayout1"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="Login Phone"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/loginphone" />
<EditText
android:id="@+id/login"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="number"
android:numeric="integer"
android:phoneNumber="true" />
<TextView
android:text="Mobile Pin"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/mobilepin" />
<EditText
android:id="@+id/pin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:numeric="integer"
android:password="true" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout2"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="@+id/preference"
android:text="Preferences"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<Button
android:id="@+id/loginbutton"
android:text="Login"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<Button
android:id="@+id/exit"
android:text="Exit"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout>
</LinearLayout>
关于android - 将布局组件设置为居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6195446/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass
我正在查看instance_variable_set的文档并看到给出的示例代码是这样做的:obj.instance_variable_set(:@instnc_var,"valuefortheinstancevariable")然后允许您在类的任何实例方法中以@instnc_var的形式访问该变量。我想知道为什么在@instnc_var之前需要一个冒号:。冒号有什么作用? 最佳答案 我的第一直觉是告诉你不要使用instance_variable_set除非你真的知道你用它做什么。它本质上是一种元编程工具或绕过实例变量可见性的黑客攻击
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我正在玩HTML5视频并且在ERB中有以下片段:mp4视频从在我的开发环境中运行的服务器很好地流式传输到chrome。然而firefox显示带有海报图像的视频播放器,但带有一个大X。问题似乎是mongrel不确定ogv扩展的mime类型,并且只返回text/plain,如curl所示:$curl-Ihttp://0.0.0.0:3000/pr6.ogvHTTP/1.1200OKConnection:closeDate:Mon,19Apr201012:33:50GMTLast-Modified:Sun,18Apr201012:46:07GMTContent-Type:text/plain
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我正在尝试为我的iOS应用程序设置cocoapods但是当我执行命令时:sudogemupdate--system我收到错误消息:当前已安装最新版本。中止。当我进入cocoapods的下一步时:sudogeminstallcocoapods我在MacOS10.8.5上遇到错误:ERROR:Errorinstallingcocoapods:cocoapods-trunkrequiresRubyversion>=2.0.0.我在MacOS10.9.4上尝试了同样的操作,但出现错误:ERROR:Couldnotfindavalidgem'cocoapods'(>=0),hereiswhy:U
我正在构建一个应用程序,想知道是否将未使用的对象设置为nil是生产级编码中的常见做法。我知道这只是垃圾收集器的提示,并不总是处理对象。 最佳答案 根据这个thread如果您使用完一个成员对象,将其设置为nil将引发被引用对象被垃圾回收。如果它是局部变量,方法exit将做同样的事情。也就是说,如果您要求将成员显式设置为nil,我会质疑您的设计。 关于ruby-将对象设置为nil是否很常见?,我们在StackOverflow上找到一个类似的问题: https://