Android 如何将图像设置在活动的左下角和背景中
我想将我的应用程序的徽标设置在屏幕的左下角,并置于背景中。我想这样做的原因是允许用户修改背景颜色,如果我简单地将整个活动或布局背景设置为图像以提供相同的印象,这是不可能的 另一种提问方式是如何将图像设置到左下角和其他控件下方?Android 如何将图像设置在活动的左下角和背景中,android,background-image,Android,Background Image,我想将我的应用程序的徽标设置在屏幕的左下角,并置于背景中。我想这样做的原因是允许用户修改背景颜色,如果我简单地将整个活动或布局背景设置为图像以提供相同的印象,这是不可能的 另一种提问方式是如何将图像设置到左下角和其他控件下方? <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@drawable/your_desired_full_background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher_logo"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
我不知道我的理解是否正确。但你问的很简单
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="bottom|left"
android:layout_margin="10dp"
android:src="#ffff00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<!-- Put your views here -->
</LinearLayout>
</FrameLayout>
您可以根据需要更改框架布局的背景,并将徽标保留在左下角。
此外,您还可以将LinearLayout(您可以使用任何布局。这取决于您)背景设置为透明,以便您可以看到背景。线性布局(视图容器)中的任何额外视图都将始终位于顶部。只需使用RelativeLayout并设置ImageView属性
android:layout\u alignParentBottom=“true”
和android:layout\u alignParentLeft=“true”
android:layout\u alignParentLeft=“true”通常默认情况下为true,但这仍然是一个很好的实践,可以具体说明我在哪里放置我的RelativeLayout-Left意味着图像将位于左上角而不是左下角。我想活动控件显示在我的图片上方,但这似乎并没有回答问题的“背景”部分。这是否能确保图片位于活动控件的“下方”,并给人以背景图片的印象?是的。如果将控件放在内部布局(在本例中为LinearLayout)中,它们将位于图像(徽标)的顶部。但请确保嵌套的布局不会太多。你可以查看谷歌的文档。是重力属性使图像显示在其余控件的“下方”吗?不是。在FrameLayout中。订单中的第一项将在底部。像堆栈一样。因此,在本例中,LinearLayout将是最后一项,它位于顶部。重力只会确保二维的投影。那么我应该把我的布局和它的所有控件放在哪里呢?我希望图像在背景中,对吗?这会不会导致图像在前景中干扰所有控件?您希望徽标作为左下角的背景?就像页脚徽标一样?如果我对前面评论的假设是正确的,那么您需要使用@Engin建议的FrameLayout。与页脚徽标不同,页脚徽标建议它与我的控件处于相同的z索引级别