android的表格布局错误。问题是,我想移动按钮到1列在第二行使用属性column_layout在2 tablerow。我已经找到解决办法了。请检查我的答案。
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TableLayoutActivity"
android:orientation="vertical"
<TableRow>
<Button android:id="@+id/firstButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/myFirstbtn"/>
<Button android:id="@+id/ThirdButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/myThirdbtn"/>
<Button android:id="@+id/FourthButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/myFourthbtn"/>
</TableRow>
<TableRow>
<Button android:id="@+id/secButton"
android:layout_column="1"
android:text="@string/mySecbtn"/>
</TableRow>
我已经删除了weight属性并删除了android:layout_width="0dp"。我有插入android:layout_width="wrap_content"代替。问题解决了。
<TableLayout 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"
tools:context=".TableLayoutActivity"
android:orientation="vertical"
>
<TableRow>
<Button android:id="@+id/firstButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/myFirstbtn"/>
<Button android:id="@+id/ThirdButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/myThirdbtn"/>
<Button android:id="@+id/FourthButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/myFourthbtn"/>
</TableRow>
<TableRow>
<Button android:id="@+id/secButton"
android:layout_column="1"
android:text="@string/mySecbtn"/>
</TableRow>
</TableLayout>