【问题标题】:How to make a (buttons on)screen responsive while using relative layout in android studio?如何在android studio中使用相对布局时使(按钮)屏幕响应?
【发布时间】:2019-01-03 06:47:41
【问题描述】:
【问题讨论】:
标签:
android
android-linearlayout
responsive
android-relativelayout
【解决方案1】:
你可以试试这样的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Button One" />
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Button Two" />
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Button Three" />
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Button Four" />
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Button Five" />
<android.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
更高的屏幕:
屏幕更短: