From 3bd360a7ee1e5e8938f1a3ae934f4e348d07ed82 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 2 Feb 2017 19:18:41 -0500 Subject: [PATCH] Added margin between pages in tab layouts. (tiny change) --- .../main/java/com/keylesspalace/tusky/AccountActivity.java | 5 +++++ app/src/main/java/com/keylesspalace/tusky/MainActivity.java | 5 +++++ app/src/main/res/drawable/tab_page_margin.xml | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 app/src/main/res/drawable/tab_page_margin.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 4b78b80fe..e4383b7fd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -30,6 +30,7 @@ import android.support.v7.widget.Toolbar; import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.util.Log; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -106,6 +107,10 @@ public class AccountActivity extends AppCompatActivity { }; adapter.setPageTitles(pageTitles); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); + int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, + getResources().getDisplayMetrics()); + viewPager.setPageMargin(pageMargin); + viewPager.setPageMarginDrawable(R.drawable.tab_page_margin); viewPager.setAdapter(adapter); tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout.setupWithViewPager(viewPager); diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index a2a7216e1..eaf9b3667 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -27,6 +27,7 @@ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; @@ -71,6 +72,10 @@ public class MainActivity extends AppCompatActivity { }; adapter.setPageTitles(pageTitles); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); + int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, + getResources().getDisplayMetrics()); + viewPager.setPageMargin(pageMargin); + viewPager.setPageMarginDrawable(R.drawable.tab_page_margin); viewPager.setAdapter(adapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout.setupWithViewPager(viewPager); diff --git a/app/src/main/res/drawable/tab_page_margin.xml b/app/src/main/res/drawable/tab_page_margin.xml new file mode 100644 index 000000000..ebad62bde --- /dev/null +++ b/app/src/main/res/drawable/tab_page_margin.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file