[英]I am not able to add 5th column in the my code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="100"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/reletive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Hello World!"
android:textSize="30sp" />
<TextView
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/output"
android:gravity="end"
android:text="Hello World!"
android:textSize="30sp" />
</RelativeLayout>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/reletive"
android:numColumns="5"
tools:ignore="InvalidId">
<Button
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="1"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="2"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="3"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="4"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="1"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="2"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="3"
android:layout_columnWeight="1"
android:text="1" />
<Button
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="4"
android:layout_columnWeight="1"
android:text="1" />
</GridLayout>
</RelativeLayout>
I use GridLayout in the under of Relative Layout. 我在相对布局的下面使用GridLayout。 I want to add 5 column in this But Not added.
我想在此添加5列但未添加。 When I add 5 the column this is behave very bad.
当我添加5列时,这表现得非常糟糕。 I want to make scientific Calculator And I want to use the Grid layout to arrange my all button.
我想制作科学计算器我想使用网格布局来安排我的所有按钮。
I want to use 5X7 Table to arrange My all button. 我想用5X7表来安排我的全部按钮。 I try several times but I am not able to add 5th column in my code.
我尝试了几次,但我无法在代码中添加第5列。
Simply removing the android:layout_columnWeight="1"
and android:layout_rowWeight="1"
will fix the problem. 简单地删除
android:layout_columnWeight="1"
和android:layout_rowWeight="1"
将解决问题。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="100">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/reletive" >
<TextView
android:id="@+id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Hello World!"
android:gravity="end" />
<TextView
android:id="@+id/input"
android:layout_below="@+id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Hello World!"
android:gravity="end"/>
</RelativeLayout>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="InvalidId"
android:layout_below="@+id/reletive"
android:numColumns="5">
<Button
android:layout_row="0"
android:layout_column="0"
android:text="1"/>
<Button
android:layout_row="0"
android:layout_column="1"
android:text="1"/>
<Button
android:layout_row="0"
android:layout_column="2"
android:text="1"/>
<Button
android:layout_row="0"
android:layout_column="3"
android:text="1"/>
<Button
android:layout_row="0"
android:layout_column="4"
android:text="1"/>
<Button
android:layout_row="1"
android:layout_column="0"
android:text="1"/>
<Button
android:layout_row="1"
android:layout_column="1"
android:text="1"/>
<Button
android:layout_row="1"
android:layout_column="2"
android:text="1"/>
<Button
android:layout_row="1"
android:layout_column="3"
android:text="1"/>
<Button
android:layout_row="1"
android:layout_column="4"
android:text="1"/>
</GridLayout>
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.