I want to make visible top part of the screen via RelativeLayout
to display two TextView
verticaly and below display ViewPager
but somehow ViewPager
fits all screen space.
How to fix it? Thanks!
<FrameLayout 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:orientation="vertical"
tools:context="android.apps.abc.company.tracks.Activities.UnitDetailsActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textViewUnitName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:textSize="20dp" />
<TextView
android:id="@+id/textViewDriverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:textSize="18dp" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip_ud"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</RelativeLayout>
</FrameLayout>
Try this way:
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUnitName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:textSize="20dp" />
<TextView
android:id="@+id/textViewDriverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:textSize="18dp" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip_ud"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</LinearLayout>
Hope this helps you...if you need any help you can ask
Try this,
<FrameLayout 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:orientation="vertical"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="@+id/rel_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textViewUnitName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:textSize="20dp" />
<TextView
android:id="@+id/textViewDriverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/textViewUnitName"
android:textSize="18dp" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/rel_main"
android:layout_marginTop="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip_ud"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</RelativeLayout>
</FrameLayout>
you can also make this change and no need to include extra relative parent view group.
<RelativeLayout 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:orientation="vertical"
tools:context="android.apps.abc.company.tracks.Activities.UnitDetailsActivity">
<RelativeLayout
android:id="@+id/rlSubParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textViewUnitName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:textSize="20dp" />
<TextView
android:id="@+id/textViewDriverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:textSize="18dp" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_below="@+id/rlSubParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip_ud"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</RelativeLayout>
You can make using only one relative layout.
<RelativeLayout
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:orientation="vertical">
<TextView
android:id="@+id/textViewUnitName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:textSize="20dp" />
<TextView
android:id="@+id/textViewDriverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewUnitName"
android:text="User"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/textViewUnitName"
android:textSize="18dp" />
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textViewDriverName"
android:layout_marginTop="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip_ud"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.