Added margin between pages in tab layouts. (tiny change)

This commit is contained in:
Vavassor 2017-02-02 19:18:41 -05:00
parent 887e68700a
commit 3bd360a7ee
3 changed files with 15 additions and 0 deletions

View file

@ -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);

View file

@ -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);

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/gray" />
</shape>