首先,我是 Android 开发的新手,所以这可能是一个简单的问题,但我真的无法让它工作。
我有以下布局。
<?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:weightSum="1">
<FrameLayout android:id="@+id/navigationBarFrameLayout"
android:layout_width="fill_parent"
android:layout_height="44dp">
<ImageView android:id="@+id/navigationBar"
android:src="@drawable/navigationbar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"/>
<TextView android:text="TextView"
android:layout_width="fill_parent"
android:id="@+id/navigationBarTitle"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold"
android:shadowColor="#fff"
android:shadowDy="-1"
android:shadowDx="0"
android:shadowRadius="1"/>
</FrameLayout>
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:id="@+id/DayPager"
android:layout_height="82dp">
</android.support.v4.view.ViewPager>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/relativeLayout">
<HorizontalScrollView android:id="@+id/ScheduleScrollView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:fadingEdge="none"
android:layout_above="@+id/tabBarFrameLayout"
android:scrollbars="none"
android:background="#00ff00">
<RelativeLayout android:id="@+id/ScheduleRelativeLayout"
android:layout_height="fill_parent"
android:layout_width="wrap_content">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/ScheduleTimelineRelativeLayout">
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/ScheduleConcertsRelativeLayout"
android:layout_below="@+id/ScheduleTimelineRelativeLayout"
android:background="#ff0000"
android:layout_weight="1">
</RelativeLayout>
</RelativeLayout>
</HorizontalScrollView>
<FrameLayout android:id="@+id/tabBarFrameLayout"
android:layout_height="49dp"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<ImageView android:id="@+id/imageView1"
android:src="@drawable/tabbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
您看到的是我有一个水平 ScrollView (ScheduleScrollView),它有两个相对布局。上面的包含时间线 (ScheduleTimelineRelativeLayout),而下面的 (ScheduleConcertsRelativeLayout) 将包含一些以编程方式创建的按钮。水平 ScrollView 与时间轴一样宽。我希望较低的相对布局填充它的父级,这意味着它应该与水平 ScrollView 一样宽,但这不起作用。
我搜索了这个论坛,试图找到我的问题的答案。有人建议使用 android:layout_width="match_parent" 但这样做时,我会收到以下错误:
Error: String types not allowed (at 'layout_width' with value 'match_parent')
其他人建议设置 android:layout_weight="1" 但这不会改变任何东西(而且该设置在我的自动完成中不可用,所以它似乎不存在)
下面的屏幕截图显示了我的问题。绿色部分是我的水平 ScrollView 的背景色。这不应该是可见的。相反,下面的红色部分应该到边缘。
更新:
更新:
在布局完成后以编程方式设置 ScheduleConcertsRelativeLayout 的宽度和高度是可行的。
RelativeLayout timeline = (RelativeLayout) findViewById(R.id.ScheduleTimelineRelativeLayout);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(timeline.getWidth(), scheduleConcertsRelativeLayout.getHeight());
params.setMargins(0, timeline.getHeight(), 0, 0);
scheduleConcertsRelativeLayout.setLayoutParams(params);
最佳答案
我可能在这里遗漏了一些东西,但您是否尝试更改:
<HorizontalScrollView android:id="@+id/ScheduleScrollView" android:layout_width="wrap_content" ... \>
到
<HorizontalScrollView android:id="@+id/ScheduleScrollView" android:layout_width="fill_parent" ... \>
关于java - 相对布局 fill_parent 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7674342/
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
这个问题在这里已经有了答案:Arraysmisbehaving(1个回答)关闭6年前。是否应该这样,即我误解了,还是错误?a=Array.new(3,Array.new(3))a[1].fill('g')=>[["g","g","g"],["g","g","g"],["g","g","g"]]它不应该导致:=>[[nil,nil,nil],["g","g","g"],[nil,nil,nil]]
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'