我对android-studio-warning有个问题。这是关于我用来把两个按钮并排放在一起的TableLayout。Android-Studio说'TableRow‘布局或者它的'TableLayout’父布局是没用的。所以我问我如何简化这段代码:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:stretchColumns="1,0"
android:layout_below="@id/dialog_cp_playlistname"
android:layout_centerVertical="true">
<TableRow >
<Button
android:id="@+id/dialog_cp_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:fontFamily="sans-serif-thin"
android:gravity="end|center_vertical"
android:paddingStart="0dp"
android:paddingEnd="25dp"
android:text="@string/object_cancel"
android:textColor="@color/white_70"
android:textSize="13sp"
android:textStyle="bold" />
<Button
android:id="@+id/dialog_cp_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:fontFamily="sans-serif-thin"
android:gravity="start|center_vertical"
android:paddingStart="25dp"
android:paddingEnd="0dp"
android:text="@string/object_next"
android:textColor="@color/accent_color"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>也许有人知道如何做到这一点。
我期待着回复。
发布于 2020-02-12 19:29:54
答案是使用weight
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>祝你编码愉快!
https://stackoverflow.com/questions/59505303
复制相似问题