紫色和绿色矩形是相对布局中的线性布局。如果绿色布局可见性设置为 GONE ,则需要进行设置,然后紫色布局将位于屏幕底部。
有人可以帮助我实现这个目标吗?
我没有设法找到这个问题的相关问题,因为很难对这类问题进行正确的问题查询。
答案 0 :(得分:1)
您可以LinearLayout
与gravity
bottom
和orientation = vertical
一起使用visibility = gone
。现在,当您为较低的布局设置<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/fisrt"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/holo_green_dark"
android:orientation="horizontal"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/holo_purple"
android:orientation="horizontal"></LinearLayout>
</LinearLayout>
</RelativeLayout>
时,上面的一个会自动降到最低点。
a = ['A', 'B', 'B', 'C', 'D', 'D']
a.each_index do |i|
if i < a.length - 1 && a[i+1] == a[i]
puts "This is not the last occurrence of #{a[i]}"
else
puts "This is the last occurrence of #{a[i]}"
end
end
# Output:
# This is the last occurrence of A
# This is not the last occurrence of B
# This is the last occurrence of B
# This is the last occurrence of C
# This is not the last occurrence of D
# This is the last occurrence of D