我有一个 Android UI 问题,我不太确定如何解决。我有一个标签主机,上面有几个不同的项目。在一种情况下,添加到 ScrollView (位于其中一个选项卡上)的字段将被动态添加。我在屏幕底部有一个按钮,使用相对布局。问题是 ScrollView (和其他选项卡的线性布局)超出了底部按钮。这导致屏幕上的最终字段不可见,因为它被按钮隐藏了。这是问题的屏幕截图以及我的布局的 xml。任何帮助是极大的赞赏。
主要布局:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_nologo" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<View android:layout_width="fill_parent"
android:layout_height="2dip"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/mc_message_send_tab_details"/>
<!-- Scrollview for message data -->
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:id="@+id/formTab">
<!-- Form fields are automatically
created in McMessageViewActivity. -->
<LinearLayout android:id="@+id/formLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View android:layout_width="fill_parent"
android:layout_height="5dip"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>
<RelativeLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true" >
<Button android:text="Send"
android:id="@+id/btnSend" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_width="0px"/>
</LinearLayout>
</RelativeLayout>
</TabHost>
额外的标签布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/detailsTab">
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<View android:layout_width="fill_parent"
android:layout_height="10dip"/>
<TableRow>
<TextView
android:text="Unit #"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<Spinner android:id="@+id/unitNumber"
android:text=""
android:padding="3dip"
android:layout_marginRight="2sp"/>
</TableRow>
<TableRow>
<TextView
android:text="User ID"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<EditText android:id="@+id/userId"
android:text=""
android:padding="3dip"
android:layout_marginRight="2sp" />
</TableRow>
<TableRow>
<TextView
android:text="Form #"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<Spinner android:id="@+id/formNumber"
android:text=""
android:padding="3dip"
android:layout_marginRight="2sp" />
</TableRow>
<TableRow>
<TextView
android:text="Sending status"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<EditText android:id="@+id/sendingStatus"
android:text=""
android:padding="3dip"
android:layout_marginRight="2sp"/>
</TableRow>
<TableRow>
<TextView
android:text="Delivery priority"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<EditText android:id="@+id/priority"
android:text=""
android:padding="3dip"
android:layout_marginRight="2sp"/>
</TableRow>
<TableRow>
<TextView
android:text="Request reply"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<CheckBox android:id="@+id/requestReply"
android:padding="3dip"
android:layout_marginRight="2sp" />
</TableRow>
<TableRow>
<TextView
android:text="Receipt conf"
android:textStyle="bold"
android:gravity="right"
android:padding="3dip" />
<CheckBox android:id="@+id/receiptConfirmation"
android:padding="3dip"
android:layout_marginRight="2sp" />
</TableRow>
</TableLayout>
</LinearLayout>
最佳答案
您的主要问题是由于 TabHost 扩展了 FrameLayout。这就是您在主布局上使用最后一个 RelativeLayout 的原因。你试图作弊,但你输了……:)
您需要做的是将一个独特的 View (例如 RelativeLayout)放入 TabHost,然后将所有其他 View 放入其中。
类似于以下内容(我必须删除一些 <includes /> 和背景才能使其在我的计算机上运行):
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<View
android:id="@+id/separator"
android:layout_below="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="2dip" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_below="@+id/separator"
android:layout_above="@+id/btnSend"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Scrollview for message data -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:id="@+id/formTab">
<!--
Form fields are automatically created in
McMessageViewActivity.
-->
<LinearLayout
android:id="@+id/formLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="5dip" />
</LinearLayout>
</ScrollView>
</FrameLayout>
<!-- Unnecessary <LinearLayout-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_width="fill_parent"-->
<!-- android:layout_alignParentBottom="true">-->
<Button
android:layout_alignParentBottom="true"
android:text="Send"
android:id="@+id/btnSend"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<!-- </LinearLayout>-->
</RelativeLayout>
</TabHost>
关于android - TabHost 上的相对布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7099035/
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我有一个.pfx格式的证书,我需要使用ruby提取公共(public)、私有(private)和CA证书。使用shell我可以这样做:#ExtractPublicKey(askforpassword)opensslpkcs12-infile.pfx-outfile_public.pem-clcerts-nokeys#ExtractCertificateAuthorityKey(askforpassword)opensslpkcs12-infile.pfx-outfile_ca.pem-cacerts-nokeys#ExtractPrivateKey(askforpassword)o
我了解instance_eval和class_eval之间的基本区别。我在玩弄时发现的是一些涉及attr_accessor的奇怪东西。这是一个例子:A=Class.newA.class_eval{attr_accessor:x}a=A.newa.x="x"a.x=>"x"#...expectedA.instance_eval{attr_accessor:y}A.y="y"=>NoMethodError:undefinedmethod`y='forA:Classa.y="y"=>"y"#WHATTT?这是怎么回事:instance_eval没有访问我们的A类(对象)然后它实际上将它添加到
我有一个集合选择:此方法的单选按钮是什么?谢谢 最佳答案 Rails3中没有这样的助手。在Rails4中,它是collection_radio_buttons. 关于ruby-on-rails-rails上的ruby:radiobuttonsforcollectionselect,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/18525986/
我正在尝试将cucumber项目的用户名和密码置于版本控制之外。有没有办法在命令行上手动将用户名和密码等变量传递给Cucumber脚本?我的备份计划是将它们放在一个YML文件中,然后将该文件添加到gitignore,这样它们就不会被置于版本控制中。 最佳答案 所以,我看到了您对铁皮人的评论,答案是肯定的。cucumberPASSWORD=my_passwordPASSWORD被设置为环境变量,您可以通过将其引用为ENV['PASSWORD']来使用它的值。例如,browser.text_field(:id=>'pwd').setEN
我刚刚迈出了编程的第一步。我刚刚完成了CodeAcademy的另一门类(class)。这次我被要求创建一个小电影目录。这是我的问题:如何在文件中保存/加载带有电影标题和评级的哈希值而不是自己的代码?下面是代码现在的样子(几句葡萄牙语,但您可以忽略它:movies={Memento:3,Primer:4,Ishtar:1}puts"Oquevocêgostariadefazer?"puts"--Digite'add'paraadicionarumfilme."puts"--Digite'update'paraatualizarumfilme."puts"--Digite'display'