在其中一种布局中,我正在使用 scrollview 并希望以编程方式设置其 layoutMarginBottom。我该怎么做?这是 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="90.0dip"
android:layout_marginLeft="1.0dip"
android:layout_marginRight="1.0dip"
android:layout_marginTop="-2.0dip"
android:animateLayoutChanges="true"
android:fadeScrollbars="true"
android:fadingEdge="none" >
<!-- android:layout_marginBottom="60.0dip" -->
<!-- android:fillViewport="true" -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible" >
<ImageView
android:id="@+id/QuestionImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible" />
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/QuestionImageView"
android:fadingEdge="vertical"
android:scrollbars="vertical" />
<TextView
android:id="@+id/questionnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fadingEdge="vertical"
android:scrollbars="vertical" />
<TextView
android:id="@+id/question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/tv"
android:fadingEdge="vertical"
android:padding="10dp"
android:scrollbars="vertical"
android:text=""
android:textColor="@color/dark_green" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/question"
android:orientation="vertical" >
<RadioButton
android:id="@+id/option1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="1.0dp"
android:background="@drawable/thinnest_blue_gradient" />
<RadioButton
android:id="@+id/option2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="1.0dp"
android:background="@drawable/thinnest_blue_gradient" />
<RadioButton
android:id="@+id/option3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="1.0dp"
android:background="@drawable/thinnest_blue_gradient" />
<RadioButton
android:id="@+id/option4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</RadioGroup>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativequestion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="a1501e5633125fb"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, 123456789ABCDEF" />
<LinearLayout
android:id="@+id/newquestion"
android:layout_width="fill_parent"
android:layout_height="40.0dip"
android:layout_above="@id/ad"
android:background="#ff777777"
android:orientation="horizontal" >
<Button
android:id="@+id/PrevButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="5.0dip"
android:layout_weight="1.0"
android:background="@drawable/ibtn"
android:onClick="onPrevButtonClick"
android:text="Prev" />
<Button
android:id="@+id/NextButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="5.0dip"
android:layout_weight="1.0"
android:background="@drawable/ibtn"
android:onClick="onNextButtonClick"
android:text="Next" />
<Button
android:id="@+id/SkipButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="5.0dip"
android:layout_weight="1.0"
android:background="@drawable/ibtn"
android:onClick="onSkipButtonClick"
android:text="Skip" >
</Button>
<Button
android:id="@+id/SubmitButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="5.0dip"
android:layout_marginRight="5.0dp"
android:layout_weight="1.0"
android:background="@drawable/ibtn"
android:onClick="onSubmitButtonClick"
android:text="Submit" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
这里我想设置 ScrollView 的layoutMarginBottom。请帮助我。在此先感谢。
最佳答案
我是这样实现的:
sv = (ScrollView)findViewById(R.id.scrollView);
sv.setBackgroundColor(Color.TRANSPARENT);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) sv
.getLayoutParams();
layoutParams.setMargins(0, 0, 0, 100);
sv.setLayoutParams(layoutParams);
关于android - 如何以编程方式设置 scrollview 的 layoutMarginBottom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12550168/
我有一个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
我试图获取一个长度在1到10之间的字符串,并输出将字符串分解为大小为1、2或3的连续子字符串的所有可能方式。例如:输入:123456将整数分割成单个字符,然后继续查找组合。该代码将返回以下所有数组。[1,2,3,4,5,6][12,3,4,5,6][1,23,4,5,6][1,2,34,5,6][1,2,3,45,6][1,2,3,4,56][12,34,5,6][12,3,45,6][12,3,4,56][1,23,45,6][1,2,34,56][1,23,4,56][12,34,56][123,4,5,6][1,234,5,6][1,2,345,6][1,2,3,456][123
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在查看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上找到一个类似的问
question的一些答案关于redirect_to让我想到了其他一些问题。基本上,我正在使用Rails2.1编写博客应用程序。我一直在尝试自己完成大部分工作(因为我对Rails有所了解),但在需要时会引用Internet上的教程和引用资料。我设法让一个简单的博客正常运行,然后我尝试添加评论。靠我自己,我设法让它进入了可以从script/console添加评论的阶段,但我无法让表单正常工作。我遵循的其中一个教程建议在帖子Controller中创建一个“评论”操作,以添加评论。我的问题是:这是“标准”方式吗?我的另一个问题的答案之一似乎暗示应该有一个CommentsController参
几个月前,我读了一篇关于rubygem的博客文章,它可以通过阅读代码本身来确定编程语言。对于我的生活,我不记得博客或gem的名称。谷歌搜索“ruby编程语言猜测”及其变体也无济于事。有人碰巧知道相关gem的名称吗? 最佳答案 是这个吗:http://github.com/chrislo/sourceclassifier/tree/master 关于ruby-寻找通过阅读代码确定编程语言的rubygem?,我们在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
我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r