开发者

android TabLayout being obscured by overlapping content in view

开发者 https://www.devze.com 2023-04-13 04:41 出处:网络
I created a tabLayout using the TabActivity and made it positioned at the bottom instead of at the top. Now, my issue is that when the view content exceeds the boundaries it covers up the tab bar. How

I created a tabLayout using the TabActivity and made it positioned at the bottom instead of at the top. Now, my issue is that when the view content exceeds the boundaries it covers up the tab bar. How do I fix it and make the top of the tab bar the bottom of the screen especially when I'm using the scrollview.

Here is my main.xml that contain the tab bar:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&开发者_JAVA技巧gt;
    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:gravity="bottom"
            android:layout_alignParentBottom="true"/>

    </RelativeLayout>
    <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"></FrameLayout>
</TabHost>

and the Activity:

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = getTabHost();

        // Tab for Photos
        TabSpec photospec = tabHost.newTabSpec("Photos");
        // setting Title and Icon for the Tab
        photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);

        // Tab for Songs
        TabSpec songspec = tabHost.newTabSpec("Songs");
        songspec.setIndicator("Songs", getResources().getDrawable(R.drawable.icon_songs_tab));
        Intent songsIntent = new Intent(this, SongsActivity.class);
        songspec.setContent(songsIntent);

        // Tab for Videos
        TabSpec videospec = tabHost.newTabSpec("Videos");
        videospec.setIndicator("Videos", getResources().getDrawable(R.drawable.icon_videos_tab));
        Intent videosIntent = new Intent(this, VideosActivity.class);
        videospec.setContent(videosIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab
        tabHost.addTab(songspec); // Adding songs tab
        tabHost.addTab(videospec); // Adding videos tab

    }


Try this for the xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">            
        <FrameLayout android:id="@android:id/tabcontent"  
            android:layout_width="fill_parent" 
            android:layout_height="0dip"
            android:layout_weight="1.0"/>
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:gravity="bottom"
            android:layout_alignParentBottom="true"/>
    </LinearLayout>
</TabHost>

Here the tab content only takes whatever space is remaining after the tab widget.

0

精彩评论

暂无评论...
验证码 换一张
取 消