如何动态更改按钮大小?

时间:2020-06-19 11:04:56

标签: android android-studio android-layout

我正在尝试使两个按钮的大小相等,但是当我更改屏幕时,如您在图像中看到的那样,按钮大小增加了。

Click here to view Image

以下是代码:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    tools:context=".Timer">

    <Button
        android:id="@+id/player1"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="#696969"
        android:text="00:00"
        android:textSize="95sp" />

    <RelativeLayout
        android:id="@+id/rl1"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_below="@+id/player1">

        <ImageButton
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_centerInParent="true"
            android:src="@drawable/ic_baseline_pause_circle_outline_24"
            android:scaleType="centerCrop"
            android:background="@android:color/transparent"/>
    </RelativeLayout>

    <Button
        android:id="@+id/player2"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_below="@+id/rl1"
        android:layout_alignParentBottom="true"
        android:background="#696969"
        android:text="00:00"
        android:textSize="95sp" />
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

使用LinearLayout作为父级,并为子级提供权重以实现结果。

could not find any suitable subnets for creating the ELB

相关问题