gpt4 book ai didi

android - 将按钮样式设置为看起来像 EditText(但仍然表现得像按钮)

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:07:21 25 4
gpt4 key购买 nike

我意识到这样做有点奇怪,但我有一个按钮需要看起来像一个 EditText,但仍然像一个按钮。我的布局 XML 目前看起来像这样:

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/editTextStyle" />

这使它具有 EditText 的外观,但也通过阻止触发 onClick 事件,除非按钮具有焦点(有效地使其需要两次单击),从而稍微扰乱了行为。有没有办法在不改变按钮行为的情况下保持样式?

我想只制作一个看起来像 EditText 的九色补丁背景,但有这么多不同的 Android 版本和皮肤,如果可能的话我宁愿使用系统样式。

最佳答案

行为类似于按钮的 EditText 怎么样?

<EditText android:id="@+id/Edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="true"/>

您也可以为它定义一个 OnClickListener。而且它不会获得焦点。

关于android - 将按钮样式设置为看起来像 EditText(但仍然表现得像按钮),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8303269/

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