一旦微调器有条目,布局就会混乱

发布于 2024-10-10 02:27:05 字数 1116 浏览 0 评论 0原文

我有

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/LinearLayoutPlayer"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <Spinner 
            android:id="@+id/Spinner01"
            android:layout_width="fill_parent"  
            android:layout_height="wrap_content"
            android:layout_weight="100" />

        <ToggleButton 
            android:text="@+id/ToggleButton01"
            android:id="@+id/ToggleButton01" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_weight="1" />
</LinearLayout>

它显示一个 spinner 和它旁边的一个 ToggleButton。到目前为止一切都还好。当然,spinner 需要一些条目,因此我向微调器添加了以下属性:

android:entries="@array/myentries"

现在的问题是 ToggleButton 比微调器和按钮要低一些。 ToggleButton 被切断,可能有 3 或 5 行像素。

有人知道这里出了什么问题吗? Android 版本是 2.2

谢谢!

I have

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/LinearLayoutPlayer"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <Spinner 
            android:id="@+id/Spinner01"
            android:layout_width="fill_parent"  
            android:layout_height="wrap_content"
            android:layout_weight="100" />

        <ToggleButton 
            android:text="@+id/ToggleButton01"
            android:id="@+id/ToggleButton01" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_weight="1" />
</LinearLayout>

Which displays a spinner and a next to its a ToggleButton. Everything okay so far. Of course the spinner need some entries, so I add to the spinner the attribute:

android:entries="@array/myentries"

The problem now is that the ToggleButton is a bit lower than the spinner and the button of the ToggleButton is cut off, maybe 3 or 5 lines of pixels.

Anyone an idea what is wrong here? Android is version 2.2

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待天淡蓝洁白时 2024-10-17 02:27:05

尝试将您的 ToggleButton 包装在新的 LinearLayout 中。那么你的 xml 将是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayoutPlayer"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Spinner 
        android:id="@+id/Spinner01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:entries="@array/planets_array"
        android:layout_weight="100">
    </Spinner>
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <ToggleButton
            android:text="@+id/ToggleButton01"
            android:id="@+id/ToggleButton01" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" 
            android:layout_weight="1">
        </ToggleButton>
    </LinearLayout>
</LinearLayout>

Try wrapping your ToggleButton in a new LinearLayout. Your xml would then be:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayoutPlayer"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Spinner 
        android:id="@+id/Spinner01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:entries="@array/planets_array"
        android:layout_weight="100">
    </Spinner>
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <ToggleButton
            android:text="@+id/ToggleButton01"
            android:id="@+id/ToggleButton01" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" 
            android:layout_weight="1">
        </ToggleButton>
    </LinearLayout>
</LinearLayout>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文