Android 布局充气机中的按钮大小不尽相同
我正在使用inflate进行android中的一项活动。我从数据库中检索到的所有信息都是正确的,但是由于某些原因,按钮的宽度看起来不一样,我不知道为什么?这是一个布局充气器,因此从数据库获取的数据越多,有两个文本视图和一个按钮的按钮行就越多 下面是XML代码Android 布局充气机中的按钮大小不尽相同,android,android-layout,button,layout-inflater,Android,Android Layout,Button,Layout Inflater,我正在使用inflate进行android中的一项活动。我从数据库中检索到的所有信息都是正确的,但是由于某些原因,按钮的宽度看起来不一样,我不知道为什么?这是一个布局充气器,因此从数据库获取的数据越多,有两个文本视图和一个按钮的按钮行就越多 下面是XML代码 <?xml version="1.0" encoding="utf-8"?> 您的宽度是包裹内容,这意味着它们将拉伸以适合内容。因此,如果在一个按钮中有一个较长的文本字符串,则该字符串将更大 此外,使用布局权重时,必
<?xml version="1.0" encoding="utf-8"?>
您的宽度是
包裹内容
,这意味着它们将拉伸以适合内容。因此,如果在一个按钮中有一个较长的文本字符串,则该字符串将更大
此外,使用布局权重时,必须根据方向将宽度或高度设置为零。请看文档中的示例:
<EditText
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="@string/message" />
高度设置为零:)
我只能看到一个按钮?哪个公司想要相同的尺寸?因为这是一个布局充气器,DB中的每个条目都有一行,有两个文本视图和一个按钮,您想要相同的宽度或高度?高度不是问题,宽度是当我更改布局宽度的大小时,我仍然在每一行中都有不同大小和宽度的按钮。谢谢,我需要将我表格行中所有内容的宽度更改为0dp
<EditText
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="@string/message" />
<TableRow
android:id="@+id/visitorNotLeft"
android:layout_width="fill_parent" --you can change this to fill_parent
android:paddingTop="20dp"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/names"
android:layout_width="0dp" --you can change this to 0dp
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:paddingLeft="50dp"
android:text="" />
<TextView
android:id="@+id/companies"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:text="" />
<Button
android:id="@+id/timeOut"
android:layout_width="0dp" --you can change this to 0dp
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:background="@drawable/appsignout_button"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="" />
</TableRow>