gpt4 book ai didi

android - 如何在 Android 中向 KeyboardView 添加填充?

转载 作者:行者123 更新时间:2023-11-29 01:30:32 25 4
gpt4 key购买 nike

我有一排 key 。每个键的宽度为 18.5%,间隙为 2%。但是,我希望第一个键的间隙为 10%,最后一个键的间隙为 右侧的 10%。在每个键上设置 horizo​​ntalGap 来实现这种效果很简单,除了我看不到设置右侧间隙的方法。

我想要的间距如下(括号内是key,否则就是gap):

10% [18.5%] 2% [18.5%] 2% [18.5%] 2% [18.5%] 10%

我试过:

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="18.5%p"
android:horizontalGap="2%"
android:keyHeight="7%p">

<Row>
<Key android:codes="1" android:keyLabel="1" android:horizontalGap="10%p" />
<Key android:codes="2" android:keyLabel="2" />
<Key android:codes="3" android:keyLabel="3" />
<Key android:codes="4" android:keyLabel="4" />
</Row>
</Keyboard>

尽管 KeyboardView 宽度设置为 fill_parent,但这并没有给我 10% 的差距。我的键盘怎么能在连续的键之后有 10% 的间隙?

最佳答案

将宽度设置为 wrap_content 并在其父级内水平居中。

关于android - 如何在 Android 中向 KeyboardView 添加填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31465679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com