How do i make a fit tablayout in every screen?











up vote
0
down vote

favorite












I have made a design for TabLayout, but I can't make the size fit with 2 different screens. I use two different screens like tablet and android phone.



How can I fix it?





This is my XML file :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.inducesmile.androidmusicplayer
.fragment.LibraryFragment">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/colorMaroon">

<ImageView
android:layout_width="match_parent"
android:layout_height="102dp"
android:src="@drawable/logo1"/>

</LinearLayout>

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
app:tabTextColor="@color/colorWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorMaroon"
app:tabMode="fixed"
app:tabIndicatorColor="@color/colorGold"
app:tabTextAppearance="@style/custTab"
app:tabSelectedTextColor="@color/colorGold"
android:layout_gravity="top"/>

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

</LinearLayout>




I want to make 4 menu/fragments with TabLayout for the details, my XML was worked but the problem is the size not optimize if I run in tablet screen.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have made a design for TabLayout, but I can't make the size fit with 2 different screens. I use two different screens like tablet and android phone.



    How can I fix it?





    This is my XML file :



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.inducesmile.androidmusicplayer
    .fragment.LibraryFragment">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@color/colorMaroon">

    <ImageView
    android:layout_width="match_parent"
    android:layout_height="102dp"
    android:src="@drawable/logo1"/>

    </LinearLayout>

    <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabTextColor="@color/colorWhite"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorMaroon"
    app:tabMode="fixed"
    app:tabIndicatorColor="@color/colorGold"
    app:tabTextAppearance="@style/custTab"
    app:tabSelectedTextColor="@color/colorGold"
    android:layout_gravity="top"/>

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

    </LinearLayout>




    I want to make 4 menu/fragments with TabLayout for the details, my XML was worked but the problem is the size not optimize if I run in tablet screen.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have made a design for TabLayout, but I can't make the size fit with 2 different screens. I use two different screens like tablet and android phone.



      How can I fix it?





      This is my XML file :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.inducesmile.androidmusicplayer
      .fragment.LibraryFragment">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:background="@color/colorMaroon">

      <ImageView
      android:layout_width="match_parent"
      android:layout_height="102dp"
      android:src="@drawable/logo1"/>

      </LinearLayout>

      <android.support.design.widget.TabLayout
      android:id="@+id/tabs"
      app:tabTextColor="@color/colorWhite"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/colorMaroon"
      app:tabMode="fixed"
      app:tabIndicatorColor="@color/colorGold"
      app:tabTextAppearance="@style/custTab"
      app:tabSelectedTextColor="@color/colorGold"
      android:layout_gravity="top"/>

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

      </LinearLayout>




      I want to make 4 menu/fragments with TabLayout for the details, my XML was worked but the problem is the size not optimize if I run in tablet screen.










      share|improve this question















      I have made a design for TabLayout, but I can't make the size fit with 2 different screens. I use two different screens like tablet and android phone.



      How can I fix it?





      This is my XML file :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.inducesmile.androidmusicplayer
      .fragment.LibraryFragment">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:background="@color/colorMaroon">

      <ImageView
      android:layout_width="match_parent"
      android:layout_height="102dp"
      android:src="@drawable/logo1"/>

      </LinearLayout>

      <android.support.design.widget.TabLayout
      android:id="@+id/tabs"
      app:tabTextColor="@color/colorWhite"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/colorMaroon"
      app:tabMode="fixed"
      app:tabIndicatorColor="@color/colorGold"
      app:tabTextAppearance="@style/custTab"
      app:tabSelectedTextColor="@color/colorGold"
      android:layout_gravity="top"/>

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

      </LinearLayout>




      I want to make 4 menu/fragments with TabLayout for the details, my XML was worked but the problem is the size not optimize if I run in tablet screen.







      android android-studio android-layout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 4:41









      André Sousa

      1,092818




      1,092818










      asked Nov 18 at 19:33









      Tri Ako Nugroho

      134




      134





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364702%2fhow-do-i-make-a-fit-tablayout-in-every-screen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364702%2fhow-do-i-make-a-fit-tablayout-in-every-screen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy