android向右的图标,Android SearchView – 向右移动图标(不带ActionBar)

我有一个像这样的Android SearchView –

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:queryHint="Search the forum ..."

android:iconifiedByDefault="true"

android:id="@+id/search_forum"

android:layout_alignParentRight="true"

android:textColor="#aaa" />

这不在我的ActionBar中,它在我的活动中的其他地方.

我需要图标(搜索图标)保持在我的布局右侧.点击它应该扩展到SearchView(与ActionBar SearchView相同的行为).我试过android:layout_alignParentRight =“true”但图标保持在左侧.

任何帮助都会很棒:)

解决方法:

我找到了解决这个问题的方法.只需将布局方向设置为“rtl”,图标将位于右侧.这是我的搜索视图的代码,它按预期工作.

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layoutDirection="rtl"

android:iconifiedByDefault="true"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

标签:android,searchview

来源: https://codeday.me/bug/20190824/1707872.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值