【发布时间】:2020-05-22 19:14:09
【问题描述】:
我不知道为什么我的 Android 布局与模拟器不匹配。有谁知道为什么会发生这种情况?
这是操作表的布局代码。未正确显示的部分位于最后一个线性布局中
这是我的 activity_login.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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:orientation="vertical"
tools:context=".LoginActivity">
<ImageView
android:id="@+id/logo_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/logotitipdonk"
android:transitionName="logo_image" />
<TextView
android:id="@+id/logo_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/bungee"
android:text="Hello there, Welcome Back"
android:textColor="#000"
android:textSize="40sp"
android:transitionName="logo_text" />
<TextView
android:id="@+id/slogan_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In to continue"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_margin="5dp"
android:background="#00000000"
android:elevation="0dp"
android:text="Forget Password?" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#000"
android:text="GO"
android:textColor="#fff" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_margin="5dp"
android:background="#00000000"
android:elevation="0dp"
android:text="New User? SIGN UP"
android:textColor="#000" />
</LinearLayout>
</LinearLayout>
This is my build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.titipdonk"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
}
编辑:除了针对这个特定问题的修复之外,还有人知道为什么预览与手机上实际显示的方式不匹配吗?
【问题讨论】:
-
嗨 LoackerHD,欢迎 Stack Overflow 上的 :-) - 你能编辑你的问题吗,图片没有显示,因为它在代码块内。
标签: android-layout