2015-10-29 2 views
1

Я работаю над проектом для собак продукта, мне нужно разработать вкладки, а в нижней части окнаандроид - изменение направления крана вниз зрения

мой XML файл

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabMode="scrollable" 
     app:tabGravity="fill"/> 
</android.support.design.widget.AppBarLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/viewpager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

мой вопрос, что является наилучшей практикой для достижения этого Просмотреть

enter image description here

ответ

1

Вы можете определить вкладки в нижней части экрана, просто указав alignParentBottom в своем расположении xml. Например:

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

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

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

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_below="@android:id/tabs" > 

       <FrameLayout 
        android:id="@+id/tab_home" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 

       <FrameLayout 
        android:id="@+id/tab_video" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 

       <FrameLayout 
        android:id="@+id/tab_audio" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 
       </FrameLayout> 

       <FrameLayout 
        android:id="@+id/tab_blog" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 
       </FrameLayout> 

       <FrameLayout 
        android:id="@+id/tab_gal" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 
       </FrameLayout> 

       <FrameLayout 
        android:id="@+id/tab_more" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 
       </FrameLayout> 
      </FrameLayout> 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" //align parent bottom mainly used for move the tab to bottom of the screen. 
       android:background="@drawable/ic_launcher" 
       android:divider="@null" /> 

      <!-- android:background="#d8e49c" --> 
     </RelativeLayout> 
    </TabHost> 

</LinearLayout> 
Смежные вопросы