在图像中,我希望按钮的宽度相等。我已将列权重和行权重设置为1,但仍然无法正常工作。
我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
tools:context="com.example.agraw.basicphrases.MainActivity">
<GridLayout
android:layout_width="368dp"
android:layout_height="495dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:gravity="fill"
android:onClick="clickFunction"
android:text="Do You Speak English?"
android:tag="doyouspeakenglish"/>
</GridLayout>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
像这样编辑你的Button标签
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:gravity="fill"
android:onClick="clickFunction"
android:text="Do You Speak English?"
android:tag="doyouspeakenglish"/>