我想要 HorizontalScrollView 中最右侧的搜索按钮。
我尝试使用 android:layout_alignParentRight="true",
但它没有用
我该怎么做?
非常感谢
我的XML代码:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/folderPath_horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="@dimen/actionbar_height"
android:fadeScrollbars="false"
android:fillViewport="true"
android:scrollbarThumbHorizontal="@drawable/folder_path_scrollbar_thumb"
android:splitMotionEvents="false">
<LinearLayout
android:id="@+id/folderPath_folder_path"
android:layout_width="wrap_content"
android:layout_height="@dimen/actionbar_height"
android:gravity="center_vertical"
android:orientation="horizontal"
android:background="@color/blue_B500"
android:splitMotionEvents="false" >
<FrameLayout
android:id="@+id/chat_search"
android:layout_width="@dimen/actionbar_height"
android:layout_height="@dimen/actionbar_height"
android:background="?actionBarItemBackground">
<View
android:layout_width="@dimen/_1dp"
android:layout_height="match_parent"
android:background="@drawable/divider_line" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/Common_003"
app:srcCompat="@drawable/ic_search" />
</FrameLayout>
</LinearLayout>
最佳答案
你不能,因为 HorizontalScrollView
没有“最右边”。
HorizontalScrollView
有无限宽度,所以它不能有最右边。
将搜索 ImageView 移到 RelativeLayout 内的 HorizontalScrollView
之外,然后您可以执行 layout_alignParentRight
。
关于android - 如何在HorizontalScrollView中将FrameLayout设置到最右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45979548/