我需要使用GridLayout
來顯示兩個按鈕。一個和第二個與其他按鈕的寬度的兩倍。我想NEXT
按鈕的寬度是BACK
按鈕的兩倍,我需要一個GridLayout
。無法顯示兩個按鈕,其中一個按鈕的寬度是GridLayout中其他寬度的兩倍
我的源代碼是如下:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Calculator.Grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="3"
app:rowCount="1">
<Button
android:id="@+id/button_back"
android:layout_column="0"
android:layout_columnSpan="1"
android:layout_columnWeight="1"
android:layout_gravity="left|top"
android:background="@drawable/bg_back_button"
android:text="@string/back"
android:textColor="?attr/colorTextSecondary"
android:textSize="16sp" />
<Button
android:id="@+id/button_next"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_columnWeight="2"
android:layout_gravity="fill"
android:background="@drawable/bg_next_button"
android:text="@string/next"
android:textColor="?attr/colorTextPrimary"
android:textSize="16sp" />
</GridLayout>
希望的顯示(NEXT按鈕應返回按鈕的雙寬度):
但結果是(問題):
你需要* *'GridView控件'?或者你可以在'LinearLayout'中包裝'Button'? – Abbas
@Sandeep Shakya請檢查我的答案是完全正常的。 –
@Abbas是的,我需要一個GridLayout在我的情況。 –