【发布时间】:2020-03-08 14:44:56
【问题描述】:
我已经为不同的屏幕尺寸创建了布局,这是我的默认布局的 xml 代码 但是任何人请告诉我我应该怎么做才能支持任何屏幕尺寸的 android 设备的布局。
我需要更改我的 xml 代码吗? 要么 只是我需要修改我的xml代码?
请告诉我,以便我可以解决我的问题
xlm
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Login"
android:textSize="40sp"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif-black"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nice"
android:layout_marginTop="40dp"
android:textSize="30sp"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorStyleNormal"
android:padding="5dp"
android:layout_marginTop="30dp"
app:hintTextAppearance="@style/ErrorStyleNormal">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:hint="Username"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
app:errorEnabled="true"
app:passwordToggleEnabled="true"
app:errorTextAppearance="@style/ErrorStyleNormal"
android:layout_marginTop="20dp"
app:hintTextAppearance="@style/ErrorStyleNormal"
app:counterTextAppearance="@style/CounterStyleNormal">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:textSize="25sp"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/textViewForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:text="@string/ForgotPassword"
android:textSize="15sp" />
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:cardCornerRadius="25dp"
android:elevation="5dp"
android:padding="10dp"
android:layout_marginTop="30dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<ImageView
android:id="@+id/image"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_arrow_forward"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Login"
android:layout_toEndOf="@+id/image"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:fontFamily="sans-serif-black"
android:layout_toRightOf="@+id/image" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/To_Join_With"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:textColor="@android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/Click_here"
android:layout_gravity="center"
android:textColor="@android:color/holo_blue_bright"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
标签: android android-studio android-layout