Reputation: 859
<?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
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