Set match_parent size for content's LinearLayout in TabHost (Android)

I can't understand, why LinearLayout with ID "map_tab" (first tab) not have a height "match_parent" in fact? I have a XML-file with TabHost:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:background="#ffff" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TabHost android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tabHost_main" android:layout_gravity="center_horizontal"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent"> <!--Вкладка №1 - карта--> <LinearLayout android:id="@+id/map_tab" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!--Карта--> <HorizontalScrollView android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/map_img" android:layout_width="wrap_content" android:layout_height="match_parent" android:scaleType="centerInside"/> </ScrollView> </HorizontalScrollView> <TextView android:id="@+id/sector_advert_text" android:background="#ddffaa" android:layout_gravity="bottom" android:gravity="bottom" android:layout_width="match_parent" android:layout_height="50dp" /> </LinearLayout> <!--Вкладка №2 - акции--> <LinearLayout android:id="@+id/stock_tab" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:text="2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <!--Вкладка №3 - Маршрут --> <LinearLayout android:id="@+id/route_tab" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:text="3" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost> </LinearLayout>

Set match_parent size for content's LinearLayout in TabHost (Android)

I already try to set height to "fill_parent". It's look like "wrap_content" always. If I set height of "map_tab" to 50dp, for example, it will not OK too! Second and third tabs have this problem too. What me do to make tab's content height "match_parent"?

-------------Problems Reply------------

I solved this problem! Just change:

<TabHost
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabHost_main"
android:layout_gravity="center_horizontal">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

on:

<TabHost
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabHost_main"
android:layout_gravity="center_horizontal">

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

Good luck! :)

Category:android Views:6 Time:2017-09-02

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.229 (s). 10 q(s)