Reputation: 5520
The inner LinearLayout is gone although I have set its layout_height
to be '100dp'.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/page_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<SeekBar
android:layout_width="0dp"
android:layout_weight="10"
android:layout_height="match_parent"
android:id="@+id/seek_bar"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/toggle"/>
</LinearLayout>
</LinearLayout>
Edit: I want the orientation of inner layout to be horizontal. So I set its layout_height
to be wrap_content
. Now, it is almost done. However, something is wrong with SeekBar, the thumbnail is not central at the vertical bar.
<android.support.v4.view.ViewPager
android:id="@+id/page_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<SeekBar
android:layout_width="0dp"
android:layout_weight="10"
android:layout_height="match_parent"
android:id="@+id/seek_bar"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/toggle"/>
</LinearLayout>
Upvotes: 3
Views: 2940
Reputation: 6857
Use the weight
instead. I've modified the code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/page_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!-- app:layout_behavior="@string/appbar_scrolling_view_behavior" -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/toggle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Upvotes: 4