我非常新手并正在练习android。我正在尝试设计一个界面,其中将包含一个背景图像和带有滑动菜单的浮动容器。(更多细节请参见附加的图片)
我的布局包括一个背景图像,一个浮动在底部的带有一些图标的容器,但距底部有一些边距(请参见附加照片)
据我所知,可以通过在底部安排“相对布局”并在其中放置图像来实现此目的。这正确吗?
另外,我想将重复的透明图像添加为浮动div的背景。
请给我一个好建议或指向一个好的教程
提前感谢
我非常新手并正在练习android。我正在尝试设计一个界面,其中将包含一个背景图像和带有滑动菜单的浮动容器。(更多细节请参见附加的图片)
我的布局包括一个背景图像,一个浮动在底部的带有一些图标的容器,但距底部有一些边距(请参见附加照片)
据我所知,可以通过在底部安排“相对布局”并在其中放置图像来实现此目的。这正确吗?
另外,我想将重复的透明图像添加为浮动div的背景。
请给我一个好建议或指向一个好的教程
提前感谢
LinearLayout
并在xml
中设置layout_weight为%。100
,以表示总权重将是100
。具有layout_weight = 10
将给它分配10%
的空间分配。<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:weightSum="100">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:background="@drawable/bg"
android:orientation="horizontal"
android:tileMode="repeat" >
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5" />
</LinearLayout>
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
app:layout_heightPercent="11%"
app:layout_widthPercent="100%" />
</android.support.percent.PercentRelativeLayout>
<view android:layout_width="wrap_content"
class="net.zel.percentage.PercentageButton"
android:id="@+id/button"
android:layout_height="wrap_content"
customView:percentage_width="50"
customView:percentage_height="50"
/>
所以你可以在库中添加所需的属性
https://github.com/metrolog3005/percentage_view
layout_weight=11
,它将会占据11%的高度。对于它的父元素,我们需要设置weightSum=100
,就像例子中展示的那样。 - NcJieweight=10
的意思是它会占用高度的 100 - 10%(即90%)吗?权重越大,它们占用的空间就越少,对吧? - BakhshiweightSum
。因此高度将为<layout_weight>/<weightSum> = 10/100 = 10%
,而不是90%。如果未指定weigthSum
,则<layout_weight>
值将与其兄弟视图归一化为1。 - NcJie