01/10/2018, 08:17
RelativeLayout trong Android
Các sư huynh cho em hỏi chút.
Vấn đề đặt ra là: Em muốn sử dụng RelativeLayout để thiết kế màn hình login theo kiểu
-ImageView
-EditText: Username
-EditText: Password
-LinearLayout: Button Login và Register
Code của em:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context="pomodoro.android7.ducthangwru.testpomodoro.activities.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="60dp"
android:scaleType="fitCenter"
android:layout_marginBottom="16dp"/>
<android.support.design.widget.TextInputLayout
android:id="@id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/et_password">
<EditText
android:id="@+id/et_username"
android:hint="@string/username"
android:inputType="text"
android:imeOptions="actionNext"
android:maxLines="1"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<EditText
android:id="@+id/et_password"
android:inputType="textPassword"
android:imeOptions="actionDone"
android:hint="@string/password"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/et_password">
<Button
android:id="@+id/bt_register"
android:textColor="@color/colorAccent"
android:background="#00000000"
android:textAllCaps="false"
android:layout_marginTop="@dimen/button_margin_top"
android:layout_marginBottom="@dimen/button_margin_bottom"
android:text="@string/register"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/button_height" />
<Button
android:id="@+id/bt_login"
android:background="@drawable/shape_button"
android:textColor="#FFFFFF"
android:textAllCaps="false"
android:text="@string/login"
android:layout_marginTop="@dimen/button_margin_top"
android:layout_marginBottom="@dimen/button_margin_bottom"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/button_height" />
</LinearLayout>
</RelativeLayout>
Lỗi của em:
C:UsersDUC THANGAndroidStudioProjectsTestPomodoroappsrcmain
eslayoutactivity_login.xml
Error:(18, 21) No resource found that matches the given name (at 'id' with value '@id/et_username').
Error:(21, 31) No resource found that matches the given name (at 'layout_above' with value '@id/et_password').
C:UsersDUC THANGAndroidStudioProjectsTestPomodoroappuildintermediates
esmergeddebuglayoutactivity_login.xml
Error:(34, 21) No resource found that matches the given name (at 'id' with value '@id/et_password').
Error:(18, 21) No resource found that matches the given name (at 'id' with value '@id/et_username').
Error:(21, 31) No resource found that matches the given name (at 'layout_above' with value '@id/et_password').
Error:(34, 21) No resource found that matches the given name (at 'id' with value '@id/et_password').
Mong được các sư huynh giải đáp. Có gì không phải xin được lượng thứ.
Cảm ơn các sư huynh rất nhiều ạ!
Bài liên quan
Ví dụ dòng android:id="@id/et_username" trong <android.support.design.widget.TextInputLayout đầu tiên. Không tìm thấy cái nào có id et_username. Nếu mà sửa thì phải là android:id="@+id/id_ban_dat" bác gán ID cho nó.Tương tự với các lỗi ở dưới