Example usage for android.util TypedValue applyDimension

List of usage examples for android.util TypedValue applyDimension

Introduction

In this page you can find the example usage for android.util TypedValue applyDimension.

Prototype

public static float applyDimension(int unit, float value, DisplayMetrics metrics) 

Source Link

Document

Converts an unpacked complex data value holding a dimension to its final floating point value.

Usage

From source file:com.charjack.charjackplayer.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);//  ww  w  .j ava2 s . c  om

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

    changeColor(currentColor);

}

From source file:com.csform.android.uiapptemplate.TabMediaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_media);

    toolbar = (Toolbar) findViewById(R.id.toolbar_tab_media);
    toolbar.setTitle("Tabs media");
    setSupportActionBar(toolbar);//from w  w  w.  ja  v a 2s .c o  m
    tabs = (PagerSlidingTabStrip) findViewById(R.id.activity_tab_media_tabs);
    pager = (ViewPager) findViewById(R.id.activity_tab_media_pager);

    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(0);

    tabs.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {
        @Override
        public void onTabReselected(int position) {
            Toast.makeText(TabMediaActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.csform.android.uiapptemplate.TabUniversalActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_universal);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Tabs universal");
    setSupportActionBar(toolbar);//from   w  w w .j  a  v a2  s  .com
    tabs = (PagerSlidingTabStrip) findViewById(R.id.activity_tab_universal_tabs);
    pager = (ViewPager) findViewById(R.id.activity_tab_universal_pager);

    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(4);

    tabs.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {
        @Override
        public void onTabReselected(int position) {
            Toast.makeText(TabUniversalActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.ben.mymusicplayer.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);//from  w  w  w  .j  a  va2 s  . c om

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

    changeColor(currentColor);

    app = (BenPlayerApp) getApplication();
}

From source file:beihua.example.com.kouding_app.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);/*from   w  w w.  j  ava2 s.co m*/

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

    changeColor(currentColor);

}

From source file:com.asc_ii.bangnote.bigbang.BigBangActionBar.java

private void initSubViews() {
    Context context = getContext();

    mBorder = ContextCompat.getDrawable(context, R.drawable.bigbang_action_bar_bg);
    mBorder.setCallback(this);

    mSearch = new ImageView(context);
    mSearch.setImageResource(R.mipmap.bigbang_action_search);
    mSearch.setOnClickListener(this);
    mShare = new ImageView(context);
    mShare.setImageResource(R.mipmap.bigbang_action_share);
    mShare.setOnClickListener(this);
    mCopy = new ImageView(context);
    mCopy.setImageResource(R.mipmap.bigbang_action_copy);
    mCopy.setOnClickListener(this);

    addView(mSearch, createLayoutParams());
    addView(mShare, createLayoutParams());
    addView(mCopy, createLayoutParams());

    setWillNotDraw(false);//  w w w  .jav a2  s .c o m

    mActionGap = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
            getResources().getDisplayMetrics());
    mContentPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
}

From source file:com.csform.android.uiapptemplate.TabTravelActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_travel);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.activity_tab_travel_tabs);
    pager = (ViewPager) findViewById(R.id.activity_tab_travel_pager);
    image = (ImageView) findViewById(R.id.activity_tab_travel_image);
    ImageUtil.displayImage(image,//from   w ww.j  a v  a  2  s  .  c om
            "http://pengaja.com/uiapptemplate/newphotos/listviews/swipetodissmiss/travel/1.jpg", null);

    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(3);

    tabs.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {
        @Override
        public void onTabReselected(int position) {
            Toast.makeText(TabTravelActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.akingyin.librarys.widgets.BrowserLayout.java

private void init(Context context) {
    mContext = context;/*  www  . j a  va2  s . c  o  m*/
    setOrientation(VERTICAL);

    mProgressBar = (ProgressBar) LayoutInflater.from(context).inflate(R.layout.progress_horizontal, null);
    mProgressBar.setMax(100);
    mProgressBar.setProgress(0);
    addView(mProgressBar, LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            mBarHeight, getResources().getDisplayMetrics()));

    mWebView = new WebView(context);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    mWebView.getSettings().setBuiltInZoomControls(false);
    mWebView.getSettings().setSupportMultipleWindows(true);
    mWebView.getSettings().setUseWideViewPort(true);
    mWebView.getSettings().setLoadWithOverviewMode(true);
    mWebView.getSettings().setSupportZoom(false);
    mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);

    LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1);
    addView(mWebView, lps);

    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                mProgressBar.setVisibility(View.GONE);
            } else {
                mProgressBar.setVisibility(View.VISIBLE);
                mProgressBar.setProgress(newProgress);
            }
        }
    });

    mWebView.setWebViewClient(new WebViewClient() {

        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            mLoadUrl = url;
        }
    });

    mBrowserControllerView = LayoutInflater.from(context).inflate(R.layout.browser_controller, null);
    mGoBackBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_back);
    mGoForwardBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_forward);
    mGoBrowserBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_go);
    mRefreshBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_refresh);

    mGoBackBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (canGoBack()) {
                goBack();
            }
        }
    });

    mGoForwardBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (canGoForward()) {
                goForward();
            }
        }
    });

    mRefreshBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            loadUrl(mLoadUrl);
        }
    });

    mGoBrowserBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!TextUtils.isEmpty(mLoadUrl)) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(mLoadUrl));
                mContext.startActivity(intent);
            }
        }
    });

    addView(mBrowserControllerView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}

From source file:com.chale22.ico01.ThemeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new.");

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);

    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);/*  w  w  w .j  a v a2 s .c o m*/

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

}

From source file:com.eccyan.widget.sample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);
    setSupportActionBar(toolbar);/*from  w w w. ja v  a 2s  .  c  o m*/
    // create our manager instance after the content view is set
    mTintManager = new SystemBarTintManager(this);
    // enable status bar tint
    mTintManager.setStatusBarTintEnabled(true);
    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    changeColor(getResources().getColor(R.color.green));

    tabs.setOnTabReselectedListener(new SpinningTabStrip.OnTabReselectedListener() {
        @Override
        public void onTabReselected(int position) {
            Toast.makeText(MainActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}