我正在尝试使用 ConstraintLayout 创建布局组合。 为了简化我的案例,我的布局应该包含三个部分:
我遇到困难的部分是为第一个布局(红色)设置最大高度。似乎 ConstraintLayout 忽略了我的“最大高度声明”:
app:layout_constraintHeight_max="300dp"
这是我目前的结果(红色部分忽略了高度限制..):
这是完整的 XML:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="com.mixtiles.android.reviewOrder.ReviewOrderActivity"
tools:layout_editor_absoluteY="25dp">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<android.support.v7.widget.Toolbar
android:id="@+id/review_order_toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/red"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/red"
app:layout_constraintBottom_toTopOf="@+id/green"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="300dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
app:layout_constraintVertical_chainStyle="spread_inside">
</FrameLayout>
<FrameLayout
android:id="@+id/green"
android:layout_width="0dp"
android:layout_height="150dp"
android:background="@color/greenish"
app:layout_constraintBottom_toTopOf="@+id/pink"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/red">
</FrameLayout>
<FrameLayout
android:id="@+id/pink"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@color/pink"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/green">
</FrameLayout>
最佳答案
android:layout_height="wrap_content"
app:layout_constraintHeight_max="300dp"
app:layout_constrainedHeight="true"
一定要设置好wrap_content的高度
关于android - ConstraintLayout 不遵守最大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48887972/
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我需要用任何语言编写一个算法,根据3个因素对数组进行排序。我以度假村为例(如Hipmunk)。假设我想去度假。我想要最便宜的地方、最好的评论和最多的景点。但是,显然我找不到在所有3个中都排名第一的方法。Example(assumingthereare20importantattractions):ResortA:$150/night...98/100infavorablereviews...18of20attractionsResortB:$99/night...85/100infavorablereviews...12of20attractionsResortC:$120/night
下面有没有更优雅的方法来实现这个:输入:array=[1,1,1,0,0,1,1,1,1,0]输出:4我的算法:streak=0max_streak=0arr.eachdo|n|ifn==1streak+=1elsemax_streak=streakifstreak>max_streakstreak=0endendputsmax_streak 最佳答案 类似于w0lf'sanswer,但通过从chunk返回nil来跳过元素:array.chunk{|x|x==1||nil}.map{|_,x|x.size}.max
我有一个页面,有时加载时间超过一分钟。假设这是预期的行为并且不会改变。在这些情况下,我得到Net::ReadTimeout。请注意,这是在通过单击上一页上的按钮导航到页面之后,而不是ajax请求。因此Capybara.using_wait_time没有帮助。我尝试了一些激进的方法(其中一些我知道行不通),例如:设置page.driver.browser.manage.timeouts的implicit_wait、script_timeout和page_load。遍历整个对象空间并设置所有Selenium::WebDriver::Remote::Http::Default的timeout
我有一个散列,我想返回散列最大值的键(或键/值对)。所以,如果只有一个真正的最大值,它将返回那个键;但是,如果有多个具有相同值的键/值对,它将返回所有这些键。我如何在Ruby中完成此操作?my_hash.max_by{|k,v|v}#onlyreturnsonekey/valuepair 最佳答案 如果你想要所有对,我会做类似的事情max=my_hash.values.maxHash[my_hash.select{|k,v|v==max}] 关于Ruby-找到哈希最大值的键,我们在Sta
这是一个哈希值,用于跟踪我拥有的每种水果的数量fruits={"apples"=>10,"pears"=>15,"bananas"=>15,"grapes"=>12}我想知道哪种水果我吃得最多。如果有决胜局,则将它们全部归还。 最佳答案 #easymax_quantity=fruits.values.maxmax_fruits=fruits.select{|k,v|v==max_quantity}.keys#fastmax_quantity=-1.0/0.0max_fruits=[]fruits.eachdo|k,v|ifv>max
我有几个具有多个属性(A、B、C、D)的记录。我希望能够找到哪条记录对于给定属性(例如D)具有更高的值。我该怎么做? 最佳答案 你可能会给出max_by一看。objects=[somearrayofobjects]object_with_highest_value=objects.max_by{|obj|obj.desired_value} 关于ruby-on-rails-如何在ruby中找到跨记录的最大属性?,我们在StackOverflow上找到一个类似的问题:
我正在寻找一种优雅的方法来获取包含两个数组之间最大值的数组。意思是如果有两个数组:a=[1,5,9]b=[3,2,11]结果应该是:=>[3,5,11]假设两个数组的大小相同。我使用的代码感觉不像是用Ruby的方式来完成这个任务:c=Array.new(a.size)foriin0...a.sizec[i]=[a[i],b[i]].maxend 最佳答案 这应该有效:[a,b].transpose.map(&:max)#=>[3,5,11]transpose返回[[1,3],[5,2],[9,11]]和map(&:max)找到每个子
简而言之,我的原始代码(用Ruby编写)如下所示:#$seenisahashtomemoizepreviouslyseensets#$sparseisahashofusernamestoalistofneighboringusernames#$setisthelistofoutputclusters$seen={}defsubgraph(set,adj)hash=(set+adj).sortreturnif$seen[hash]$sets.pushset.sort.join(",")ifadj.empty?andset.size>2adj.each{|node|subgraph(set
我一直在看maxmethod在Ruby的Enumerable混合(v2.4.1)。这是一个相当简单的方法,但是当存在重复项时它如何排序项目有点令人困惑。例如:x=[1,2,3,4,5,6,7,8,9]x.max{|a,b|a%2b%2}=>110.times{|y|px.max(y){|a,b|a%2b%2}}[][1][1,7]#whyis7thenextelementafter1?[3,1,5]#whynomore7?[7,3,1,5]#7isnowfirst[9,7,3,1,5][9,7,3,1,5,6][9,7,3,1,5,4,6][9,7,3,1,5,2,4,6][9,7,5