-2

Ich habe ein Layout, wie folgend -Tabs mit benutzerdefinierter Ansicht wird das Aufblasen nicht in TabLayout am unteren Rande des Bildschirms

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:custom="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 


<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white" 
    android:orientation="vertical" 
    android:weightSum="6" 
    android:id="@+id/main_global_container" 
    > 


    <!--<include--> 
     <!--android:id="@+id/mainAppBar"--> 
     <!--layout="@layout/view_appbar" />--> 

    <!--<ProgressBar--> 
     <!--android:layout_width="match_parent"--> 
     <!--android:layout_height="wrap_content"--> 
     <!--style="@android:style/Widget.Holo.Light.ProgressBar.Large"--> 
     <!--android:layout_margin="35dp"--> 
     <!--android:id="@+id/homescreenProgressbar"--> 
     <!--android:gravity="center_horizontal"--> 
     <!--android:visibility="invisible"--> 
     <!--/>--> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:orientation="horizontal" 
     android:weightSum="3" 
     android:layout_weight="2.5" 
     android:background="@color/black" 
     android:id="@+id/upper_container"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.7" 
      android:weightSum="2" 
      android:background="@color/formInactiveFont" 
      android:id="@+id/upper_left_container" 
      android:orientation="vertical"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"> 


       <TextView 
        android:text="Welcome," 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="20dp" 
        android:layout_marginStart="20dp" 
        android:layout_marginTop="21dp" 
        android:id="@+id/textView5" 
        /> 

       <TextView 
        android:text="Devansh" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="22dp" 
        android:layout_marginStart="22dp" 
        android:layout_marginTop="42dp" 
        android:id="@+id/textView6" 
        /> 

       <TextView 
        android:text="Custome message will appear here" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="20dp" 
        android:layout_marginStart="20dp" 
        android:layout_marginTop="73dp" 
        android:id="@+id/textView7" 
        /> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        custom:srcCompat="@drawable/hexagone" 
        android:id="@+id/imageView" 
        android:layout_marginRight="12dp" 
        android:layout_centerVertical="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" 
        android:layout_marginEnd="12dp" /> 
      </RelativeLayout> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="2dp" 
       android:background="@color/black" 
       android:layout_centerHorizontal="true" 
       android:id="@+id/view4" 
       android:layout_marginTop="7dp" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp"/> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"> 


       <TextView 
        android:text="100" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="27dp" 
        android:id="@+id/textView8" 
        android:gravity="center" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" 
        android:layout_marginRight="12dp" 
        android:layout_marginEnd="12dp" 
        android:background="@drawable/hexagone"/> 

       <TextView 
        android:text="Total Score" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="23dp" 
        android:layout_marginStart="23dp" 
        android:layout_marginTop="13dp" 
        android:id="@+id/textView11" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" /> 

       <TextView 
        android:text="Begainner" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView12" 
        android:layout_centerVertical="true" 
        android:layout_alignLeft="@+id/textView11" 
        android:layout_alignStart="@+id/textView11" /> 
      </RelativeLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.3" 
      android:background="@color/accentColor" 
      android:id="@+id/upper_right_container" 
      android:orientation="vertical"> 

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


       <TextView 
        android:text="Keep Learning" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView13" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" 
        android:layout_marginTop="15dp" /> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        custom:srcCompat="@drawable/logo" 
        android:id="@+id/imageView2" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" /> 

       <Button 
        android:text="Take Quiz" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignRight="@+id/textView13" 
        android:layout_alignEnd="@+id/textView13" 
        style="@style/quizBtnHome" 
        android:id="@+id/button4" /> 
      </RelativeLayout> 

     </LinearLayout> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:orientation="vertical" 
     android:layout_weight="3.5" 
     android:id="@+id/bottom_container"> 


     <android.support.v4.view.ViewPager 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/home_view_pager"> 


     </android.support.v4.view.ViewPager> 




    </LinearLayout> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:minHeight="100dp" 
     app:tabGravity="fill" 
     app:tabMode="fixed" 

     /> 





</LinearLayout> 

i Tabs in tablayout am Aufpumpen xml-Layout mit folgenden -

<?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" 
    android:gravity="center"> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@android:drawable/star_big_on" 
    android:id="@+id/imageView3" 
    /> 

<TextView 
    android:text="Topic" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/textView10" 
    android:layout_margin="7dp" /> 

</LinearLayout> 

Dann richte ich Viewpager mit meinem Tablayout ein.

Das Problem ist, dass ich ein leeres Tab-Layout mit leeren Tabs bekomme, sie zeigen nicht ihr Layout, aber wenn ich View Pager ausschließe, dann werden sie richtig aufgeblasen und zeigen, was sie zeigen sollen.

Bitte helfen. Danke im Voraus.

+0

Zeigen Sie Ihre Layout-Code –

+0

@BurhanuddinRashid –

Antwort

0

Probieren Sie dies aus, weil LinearLayout Gewicht Ich habe Änderungen vorgenommen, um TabLayout unten und LinearLayout oben Tab Layout zu setzen.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       xmlns:custom="http://schemas.android.com/apk/res-auto" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 


    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/main_global_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white" 
     android:orientation="vertical" 
     android:weightSum="6" 
     android:layout_above="@+id/tabLayout"> 


     <!--<include--> 
     <!--android:id="@+id/mainAppBar"--> 
     <!--layout="@layout/view_appbar" />--> 

     <!--<ProgressBar--> 
     <!--android:layout_width="match_parent"--> 
     <!--android:layout_height="wrap_content"--> 
     <!--style="@android:style/Widget.Holo.Light.ProgressBar.Large"--> 
     <!--android:layout_margin="35dp"--> 
     <!--android:id="@+id/homescreenProgressbar"--> 
     <!--android:gravity="center_horizontal"--> 
     <!--android:visibility="invisible"--> 
     <!--/>--> 

     <LinearLayout 
      android:id="@+id/upper_container" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="2.5" 
      android:background="@color/black" 
      android:orientation="horizontal" 
      android:weightSum="3"> 

      <LinearLayout 
       android:id="@+id/upper_left_container" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.7" 
       android:background="@color/formInactiveFont" 
       android:orientation="vertical" 
       android:weightSum="2"> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1"> 


        <TextView 
         android:id="@+id/textView5" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" 
         android:layout_alignParentTop="true" 
         android:layout_marginLeft="20dp" 
         android:layout_marginStart="20dp" 
         android:layout_marginTop="21dp" 
         android:text="Welcome," 
         /> 

        <TextView 
         android:id="@+id/textView6" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" 
         android:layout_alignParentTop="true" 
         android:layout_marginLeft="22dp" 
         android:layout_marginStart="22dp" 
         android:layout_marginTop="42dp" 
         android:text="Devansh" 
         /> 

        <TextView 
         android:id="@+id/textView7" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" 
         android:layout_alignParentTop="true" 
         android:layout_marginLeft="20dp" 
         android:layout_marginStart="20dp" 
         android:layout_marginTop="73dp" 
         android:text="Custome message will appear here" 
         /> 

        <ImageView 
         android:id="@+id/imageView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentEnd="true" 
         android:layout_alignParentRight="true" 
         android:layout_centerVertical="true" 
         android:layout_marginEnd="12dp" 
         android:layout_marginRight="12dp" 
         custom:srcCompat="@drawable/hexagone"/> 
       </RelativeLayout> 

       <View 
        android:id="@+id/view4" 
        android:layout_width="match_parent" 
        android:layout_height="2dp" 
        android:layout_centerHorizontal="true" 
        android:layout_marginLeft="20dp" 
        android:layout_marginRight="20dp" 
        android:layout_marginTop="7dp" 
        android:background="@color/black"/> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1"> 


        <TextView 
         android:id="@+id/textView8" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentEnd="true" 
         android:layout_alignParentRight="true" 
         android:layout_alignParentTop="true" 
         android:layout_marginEnd="12dp" 
         android:layout_marginRight="12dp" 
         android:layout_marginTop="27dp" 
         android:background="@drawable/hexagone" 
         android:gravity="center" 
         android:text="100"/> 

        <TextView 
         android:id="@+id/textView11" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" 
         android:layout_alignParentTop="true" 
         android:layout_marginLeft="23dp" 
         android:layout_marginStart="23dp" 
         android:layout_marginTop="13dp" 
         android:text="Total Score"/> 

        <TextView 
         android:id="@+id/textView12" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignLeft="@+id/textView11" 
         android:layout_alignStart="@+id/textView11" 
         android:layout_centerVertical="true" 
         android:text="Begainner"/> 
       </RelativeLayout> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/upper_right_container" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.3" 
       android:background="@color/accentColor" 
       android:orientation="vertical"> 

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


        <TextView 
         android:id="@+id/textView13" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentTop="true" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="15dp" 
         android:text="Keep Learning"/> 

        <ImageView 
         android:id="@+id/imageView2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentTop="true" 
         android:layout_centerHorizontal="true" 
         custom:srcCompat="@drawable/logo"/> 

        <Button 
         android:id="@+id/button4" 
         style="@style/quizBtnHome" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignEnd="@+id/textView13" 
         android:layout_alignParentBottom="true" 
         android:layout_alignRight="@+id/textView13" 
         android:text="Take Quiz"/> 
       </RelativeLayout> 

      </LinearLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/bottom_container" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="3.5" 
      android:orientation="vertical"> 


      <android.support.v4.view.ViewPager 
       android:id="@+id/home_view_pager" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 


      </android.support.v4.view.ViewPager> 


     </LinearLayout> 
    </LinearLayout> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:minHeight="100dp" 
      app:tabGravity="fill" 
      app:tabMode="fixed" 

      /> 



</RelativeLayout> 
+0

getan Das ist nicht das Problem lösen. Übrigens können Sie bitte auf die Änderungen hinweisen, die Sie vorgenommen haben? –

+0

Ich habe Tab nach unten ausgerichtet und LinearLayout über Tab Layout –

+0

das Problem ist irgendwie mit Viewpager verwandt, denn wenn ich es ausschließe, ist das Problem gelöst –

0

ich es gelöst haben, so für jeden, der dieses Problem in Zukunft haben könnten,

entfernen getPageTitle() -Methode von Ihrem PagerAdaptor Klasse und Dinge tun, die in dieser Reihenfolge -

  1. add Fragmente zu pageradaptor.
  2. Setup pageradaptor mit Ihnen tabslayout
  3. aufblasen Tabs mit benutzerdefinierten Layout
Verwandte Themen