[英]How to make a (buttons on)screen responsive while using relative layout in android studio?
[英]How to make responsive layout for large screen in android
我在我的应用程序中使用约束布局进行设计,并将wrap_content
或match_parent
设置为宽度和高度。 当 App 在平板电脑或大屏幕上运行时,视图的尺寸越来越小。 是另一种在不为大屏幕创建另一个布局的情况下使视图更大的方法吗?
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_heart" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_count_result_search_home"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
app:cardBackgroundColor="@color/red_400"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="@id/card"
app:layout_constraintStart_toEndOf="@id/card"
app:layout_constraintTop_toTopOf="@id/card">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="65"
android:textColor="#fff"
android:textSize="18sp" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:elevation="0dp"
app:cardBackgroundColor="@color/blue"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="@id/card"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/card"
app:layout_constraintWidth_default="percent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Search"
android:textColor="#fff"
android:textSize="18sp" />
</androidx.cardview.widget.CardView>
如果你想要全视图,那么你必须使用match_parent作为宽度和高度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.