Что вы можете сделать, это ограничить ваши FrameLayout
справа налево от search_layout
, чтобы они не перекрывались. Таким образом, последний Button
будет полностью виден.
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/horizontal_scroll_container"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/search_layout">
Значение width
было изменено на 0dp
(MATCH_CONSTRAINT
), поэтому контейнер ScrollView
занимает все доступное горизонтальное пространство.
На самом деле контейнер FrameLayout
вообще не нужен. HorizontallScrollView
является подклассом FrameLayout
, поэтому нет необходимости их вкладывать. Тот же результат может быть достигнут при наличии HorizontalScrollView
в качестве прямого потомка ConstraintLayout
:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxHeight="50dp"
tools:context=".navigation.NavigationFragment">
<HorizontalScrollView
android:id="@+id/horizontal_scroll"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/search_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
style="?android:attr/borderlessButtonStyle"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
style="?android:attr/borderlessButtonStyle"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"
style="?android:attr/borderlessButtonStyle"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button4"
style="?android:attr/borderlessButtonStyle"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button5"
style="?android:attr/borderlessButtonStyle"/>
</LinearLayout>
</HorizontalScrollView>
<FrameLayout
android:id="@+id/search_layout"
android:layout_width="58dp"
android:layout_height="match_parent"
android:background="@color/colorAccent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@id/horizontal_scroll"/>
</android.support.constraint.ConstraintLayout>