【发布时间】:2017-01-17 11:57:39
【问题描述】:
这是我想在我的应用程序中实现的登录活动 (Image2)。但我不知道该怎么做,因为我无法将 editText、password 和 button 粘贴到图像的白色部分(整个图像有黑色边框)。该应用程序具有白色背景,我想将图像的外观设为曲线并将其他字段置于其下。现在它看起来像 image1。
看看这个
我还希望我的图像与底部对齐,其宽度为 match_parent 并调整高度,以便将原始图像的比例保存在不同的设备上。这是我的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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/banner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
tools:context="com.example.android.start.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
app:srcCompat="@drawable/logo"
android:id="@+id/logo"
android:layout_weight="2"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:id="@+id/back"
app:srcCompat="@drawable/image2"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/editText3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/editText2" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_centerInParent="true"/>
</LinearLayout>
【问题讨论】:
-
我认为你应该使用 FrameLayout
-
使用RelativeLayout下的widgets,把你的图片设置为背景,你的问题就解决了。
-
使用 FrameLayout,并提供第二个图像作为第二个 FrameLayout 背景。然后从顶部添加具有特定填充的编辑文本
-
谢谢@Navas pk,使用 FrameLayout 并将图像设置为背景对我有用。
标签: android android-layout android-imageview