【发布时间】:2021-12-12 08:07:56
【问题描述】:
我正在尝试创建一个具有两个背景图像和一个带有语言选择下拉菜单的文本视图的屏幕。第一个背景图像填满整个屏幕,第二个背景图像位于中心。然后我们有一个语言下拉菜单,它应该位于底部。我想实现这样的目标:
我看到 FrameLayout 为我们提供了将图像逐个嵌套的能力,但是使用我的代码,我将语言下拉菜单放在顶部而不是底部。我对 Android 很陌生,正在修复一些屏幕,非常感谢任何帮助。这是我的代码:
<FrameLayout 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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/image_1"
android:scaleType="fitXY" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dip"
android:background="@drawable/image_2" />
<LinearLayout 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:orientation="vertical"
tools:context=".ui.instructionview.WelcomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/common_10dp"
android:id="@+id/preferredData"
android:text=""
android:layout_marginBottom="@dimen/common_10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textColor="#2c5a99"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/common_20dp"
android:layout_marginRight="@dimen/common_20dp"
android:background="@drawable/bg_dashboard_line_outline">
<TextView
android:id="@+id/language_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/change_lang"
android:gravity="left"
android:padding="@dimen/common_10dp"
android:layout_marginLeft="@dimen/common_20dp"
android:text="English"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="#343f45" />
<Button
android:id="@+id/change_lang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/common_30dp"
android:backgroundTint="#183274"
android:gravity="center_vertical"
android:text="CHANGE" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
【问题讨论】:
标签: android android-layout android-linearlayout android-relativelayout android-framelayout