Android Spinner 并没有真正填充宽度
我在 RelativeLayout
中有一个非常简单的 TableLayout
。其中一行包含一个设置为“fill_width
”的微调器。在模拟器中,这看起来应该是这样,但在我的手机上,它的左右两侧距离全宽都有几个像素。表中的下一行按其应有的方式填充。还尝试将旋转器移到桌子外面,但它没有改变任何东西......
有人有任何提示吗?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0"
android:shrinkColumns="0"
>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:layout_marginTop="10dip"
android:text="@string/project_prompt"
/>
</TableRow>
<TableRow>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:prompt="@string/project_prompt"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/button_addproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Ny"
android:onClick="selfDestruct"
/>
<Button
android:id="@+id/button_modifyproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Rediger"
android:onClick="selfDestruct"
/>
<Button
android:id="@+id/button_deleteproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Slett"
android:onClick="selfDestruct"
/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/button_connect"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_centerInParent="true"
android:text="@string/connect"
/>
<ImageView
android:src="@drawable/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
/>
</RelativeLayout>
I've got a very simple TableLayout
inside a RelativeLayout
. One of the rows contains a spinner which is set to "fill_width
". In the emulator this looks as it should, but on my phone it's a couple of pixels away from full width on both left and right. The next rows in the table fill as they should. Also tried moving the spinner outside the table, but it didn't change anything...
Anyone got any tips?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0"
android:shrinkColumns="0"
>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:layout_marginTop="10dip"
android:text="@string/project_prompt"
/>
</TableRow>
<TableRow>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:prompt="@string/project_prompt"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/button_addproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Ny"
android:onClick="selfDestruct"
/>
<Button
android:id="@+id/button_modifyproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Rediger"
android:onClick="selfDestruct"
/>
<Button
android:id="@+id/button_deleteproject"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="Slett"
android:onClick="selfDestruct"
/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/button_connect"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_centerInParent="true"
android:text="@string/connect"
/>
<ImageView
android:src="@drawable/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
/>
</RelativeLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有解决方案,但可以确认这一点。我刚刚在我的设备和模拟器上的我自己的应用程序之一中检查了它。就我而言,情况并没有那么糟糕,但你可以看到其中的区别。
我认为这是系统用户界面的本质。我认为微调器使用的是 9 补丁图像,如果这个图像定义了填充,我认为您无能为力。例如,按钮在我的设备上的行为方式相同。
I don't have a solution but can confirm that. I just checked it in one of my own apps on my device and the emulator. It's not really that bad in my case but you can see the difference.
I assume it's the nature of the system UI. I think the spinner is using a 9 patch image and if this one defines a padding there's not much you can do I think. E.g. a button behaves the same way on my device.