我正在尝试显示一个 Android Activity :
我写的布局符合这些标准,除了对话框总是填满整个屏幕(见底部的垂直屏幕截图)。
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/header"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:layout_marginTop="10dp" android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:textSize="18dip" android:textColor="#ffffff"
android:text="Sample Layout" />
<LinearLayout android:id="@+id/controls" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
style="@android:style/ButtonBar">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="Yes" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="No" />
</LinearLayout>
<ScrollView android:id="@+id/test" android:layout_below="@id/header"
android:layout_above="@id/controls"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginBottom="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Integer dui odio, convallis vitae suscipit eu,
tincidunt non mi. Vestibulum faucibus pretium purus vel adipiscing.
Morbi mattis molestie risus vitae vehicula. [...]" />
</ScrollView>
</RelativeLayout>
此外,该 Activity 使用 @android:style/Theme.Dialog 和 android:windowNoTitle 设置样式。
我不确定我是否理解为什么此布局会扩展以填满整个屏幕。没有一个 View 的布局高度设置为 fill_parent;父布局也未设置为 fill_parent。
有谁知道我想做的事是否可行,如果可行,该怎么做?
最佳答案
我有一个与您的 Activity 非常相似的 Activity 。我前段时间做过,所以我真的不记得我为什么这样做和那样做,但我想我实现了你想要做的事情。这是我的代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/info_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="@color/color2">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/color1">
<TextView
android:id="@+id/infos_titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="12dip"
android:textSize="20dip"
android:textColor="@color/color2"
android:gravity="center"
android:background="@color/color1">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/infos_LL"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="@+id/infos_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dip"
android:padding="4dip"
android:textColor="@color/color1"
android:lineSpacingMultiplier="1.1"
android:autoLink="web">
</TextView>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/color1"
android:paddingTop="6dip">
<Button
android:id="@+id/infos_remarquebutton"
android:text="Faire une remarque"
android:drawableLeft="@drawable/happy"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textColor="@color/buttontext_color">
</Button>
<Button
android:id="@+id/infos_partagerbutton"
android:text="Partager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_share"
android:layout_weight="1"
android:textColor="@color/buttontext_color">
</Button>
</LinearLayout>
不要被法语命名打扰...
因此,我认为主要技巧是将 ScrollView 放在 LinearLayout 中。我还给那个 LinearLayout 赋予了 1 的权重(我不记得为什么......)。 此外,顶部布局是线性布局,而不是代码中的相对布局,但我认为它不会改变任何东西,尽管我不熟悉 RelativeLayouts。
希望对您有所帮助!
关于带有对话框主题的Android底部按钮栏和 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5274089/
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
使用rspec-rails3.0+,测试设置分为spec_helper和rails_helper我注意到生成的spec_helper不需要'rspec/rails'。这会导致zeus崩溃:spec_helper.rb:5:in`':undefinedmethod`configure'forRSpec:Module(NoMethodError)对thisissue最常见的回应是需要'rspec/rails'。但这是否会破坏仅使用spec_helper拆分rails规范和PORO规范的全部目的?或者这无关紧要,因为Zeus无论如何都会预加载Rails?我应该在我的spec_helper中做
假设我有一个类A,里面有一些方法。假设stringmethodName是这些方法之一,我已经知道我想给它什么参数。它们在散列中{'param1'=>value1,'param2'=>value2}所以我有:params={'param1'=>value1,'param2'=>value2}a=A.new()a.send(methodName,value1,value2)#callmethodnamewithbothparams我希望能够通过传递我的哈希以某种方式调用该方法。这可能吗? 最佳答案 确保methodName是一个符号,而
当我进入Rails控制台时,我已将pry设置为加载代替irb。我找不到该页面或不记得如何将其恢复为默认行为,因为它似乎干扰了我的Rubymine调试器。有什么建议吗? 最佳答案 我刚发现问题,pry-railsgem。忘记了它的目的是让“railsconsole”打开pry。 关于ruby-on-rails-带有Pry的Rails控制台,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/question
我希望用户从一个模型的三个选项中选择一个。即我有一个模型视频,可以被评为正面/负面/未知目前我有三列bool值(pos/neg/unknown)。这是处理这种情况的最佳方式吗?为此,表单应该是什么样的?目前我有类似的东西但显然它允许多项选择,而我试图将它限制为只有一个..怎么办? 最佳答案 如果要使用字符串列,让我们说rating。然后在你的表单中:#...#...它只允许一个选择编辑完全相同但使用radio_button_tag: 关于ruby-on-rails-Rails单选按钮-模
我了解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类(对象)然后它实际上将它添加到
我在一个简单的RailsAPI中有以下Controller代码:classApi::V1::AccountsControllerehead:not_foundendendend问题在于,生成的json具有以下格式:{id:2,name:'Simpleaccount',cash_flows:[{id:1,amount:34.3,description:'simpledescription'},{id:2,amount:1.12,description:'otherdescription'}]}我需要我生成的json是camelCase('cashFlows'而不是'cash_flows'
在Ruby(或Rails)中,我们可以做到new_params=params.merge({:order=>'asc'})现在new_params是一个带有添加键:order的散列。但是是否有一行可以返回带有已删除key的散列?线路new_params=params.delete(:order)不会工作,因为delete方法返回值,仅此而已。我们必须分3步完成吗?tmp_params=paramstmp_params.delete(:order)returntmp_params有没有更好的方法?因为我想做一个new_params=(params[:order].blank?||para
基本上,我试图在用户单击链接(或按钮或某种类型的交互元素)时执行Rails方法。我试着把它放在View中:但这似乎没有用。它最终只是在用户甚至没有点击“添加”链接的情况下调用该函数。我也用link_to试过了,但也没用。我开始认为没有一种干净的方法可以做到这一点。无论如何,感谢您的帮助。附言。我在ApplicationController中定义了该方法,它是一个辅助方法。 最佳答案 View和Controller是相互独立的。为了使链接在Controller内执行函数调用,您需要对应用程序中的端点执行ajax调用。该路由应调用rub
我在ruby表单中有一个提交按钮f.submitbtn_text,class:"btnbtn-onemgt12mgb12",id:"btn_id"我想在不使用任何javascript的情况下通过ruby禁用此按钮 最佳答案 添加disabled:true选项。f.submitbtn_text,class:"btnbtn-onemgt12mgb12",id:"btn_id",disabled:true 关于ruby-on-rails-如何在Rails中添加禁用的提交按钮,我们在St