RomanKovalev
RomanKovalev

Reputation: 859

make ViewPager smaller

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v4.view.ViewPager android:id="@+id/groups_of_content"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="0"/>

    <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="100"
        android:text="There are not place for me" />

</LinearLayout>

In the code above ViewPager occupies all of the place. How to make it occupy as much space as much as a content requires. As layout's "wrap_content" property.


UPD: ViewPager is filled with:

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView android:id="@+id/group_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/group_active"
        /> 
</LinearLayout>

I want to ViewPager have size as musch as TextView in code above. How to make it?

Upvotes: 0

Views: 1075

Answers (1)

Jc Mi&#241;arro
Jc Mi&#241;arro

Reputation: 1411

If you are going to use android:layout_weight you have to set the android:layout_height to 0dip like in this example.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v4.view.ViewPager android:id="@+id/groups_of_content"
        android:layout_width="fill_parent" 
        android:layout_height="0dip" 
        android:layout_weight="3"/>

    <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="0dip" 
        android:layout_weight="1"
        android:text="Must there be place for me" />

</LinearLayout>

Upvotes: 2

Related Questions