List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP
int COMPLEX_UNIT_DIP
To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.
Click Source Link
From source file:com.astuetz.viewpager.extensions.gramis.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); setSupportActionBar(toolbar);/*from w ww. ja v a 2 s. co 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); pager.setCurrentItem(0); String[] mainMenu = { "?", "?", "??", "" }; AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { switch (position) { case 0: Intent intent0 = new Intent(MainActivity.this, MainActivity.class); startActivity(intent0); break; case 1: Intent intent1 = new Intent(MainActivity.this, IconsActivity.class); startActivity(intent1); break; case 2: Intent intent2 = new Intent(MainActivity.this, ActiveActivity.class); startActivity(intent2); break; case 3: Intent intent3 = new Intent(MainActivity.this, ProfileActivity.class); startActivity(intent3); break; } } }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mainMenu); listViewMainMenu.setAdapter(adapter); listViewMainMenu.setOnItemClickListener(onItemClickListener); }
From source file:com.chale22.ico01.IconActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_icon); 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 IconPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter);/*from www. jav a 2 s.co m*/ final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); }
From source file:com.collcloud.frame.viewpager.main.PagerTabMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tab_pagertab__main); tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); pager = (ViewPager) findViewById(R.id.pager); adapter = new MyPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter);//from w w w. ja va 2s .c o m //initView(); // viewPagerAdapter = new ViewPagerAdapter(lists); // pager.setAdapter(viewPagerAdapter); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); tabs.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { /*initListView(position); clickTitleItem(position);*/ Log.i(tag, "onPageSelected position is:" + position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); changeColor(currentColor); }
From source file:com.csform.android.uiapptemplate.TabShopActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tab_shop); tabs = (PagerSlidingTabStrip) findViewById(R.id.activity_tab_shop_tabs); pager = (ViewPager) findViewById(R.id.activity_tab_shop_pager); image = (ImageView) findViewById(R.id.activity_tab_shop_image); like = (TextView) findViewById(R.id.activity_tab_shop_like); favorite = (TextView) findViewById(R.id.activity_tab_shop_favorite); share = (TextView) findViewById(R.id.activity_tab_shop_share); like.setOnClickListener(this); favorite.setOnClickListener(this); share.setOnClickListener(this); ImageUtil.displayImage(image, "http://pengaja.com/uiapptemplate/newphotos/shop/7.jpg", null); adapter = new MyPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter);//from w ww. j a v a 2 s .c om tabs.setViewPager(pager); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); pager.setCurrentItem(1); tabs.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() { @Override public void onTabReselected(int position) { Toast.makeText(TabShopActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show(); } }); }
From source file:com.dashihui.afford.ui.activity.AtyFragmentDiscount.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aty_order_frag); mTopTitle_txt = (TextView) findViewById(R.id.title); mTopTitle_txt.setText(""); mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack); mIbtnBack.setOnClickListener(this); tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs); pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager); Intent intent = getIntent();//from www . ja v a 2s .c o m //??1 2 ?? ???searchClassifyType mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1); adapter = new MyPagerAdapter(getSupportFragmentManager()); // ???N?? pager.setOffscreenPageLimit(adapter.getCount()); pager.setAdapter(adapter); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); pager.setCurrentItem(intent.getIntExtra(TABCODE, 0)); tabs.setViewPager(pager); changeColor(currentColor); }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w ww . j a v a2 s. co m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:com.dashihui.afford.ui.activity.AtyFragmentOrdert.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aty_order_frag); mTopTitle_txt = (TextView) findViewById(R.id.title); mTopTitle_txt.setText("?"); mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack); mIbtnBack.setOnClickListener(this); tabs = (WdtPagerTab) findViewById(R.id.apps_fragment_tabs); pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager); Intent intent = getIntent();// w w w .j av a 2 s . c om //??1 2 ?? ???searchClassifyType mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1); adapter = new MyPagerAdapter(getSupportFragmentManager()); // ???N?? pager.setOffscreenPageLimit(adapter.getCount()); pager.setAdapter(adapter); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); pager.setCurrentItem(intent.getIntExtra(TABCODE, 0)); tabs.setViewPager(pager); tabs.setPosition(intent.getIntExtra(TABCODE, 0)); LogUtils.e("position=============>" + intent.getIntExtra(TABCODE, 0)); tabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i1) { } @Override public void onPageSelected(int i) { FragmentOrder fragmentOrder = FragmentOrder.newInstance(AtyFragmentOrdert.this, i); } @Override public void onPageScrollStateChanged(int i) { } }); }
From source file:at.wada811.android.dialogfragments.sample.dialogfragmentcallbackprovider.DialogFragmentCallbackProviderFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override//from w ww. j a va 2 s. c om public View getView(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText("Use getChildFragmentManager()"); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } }; }
From source file:com.dashihui.afford.ui.activity.AtyFragmentService.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aty_orderserver_frag); mTopTitle_txt = (TextView) findViewById(R.id.title); mTopTitle_txt.setText("??"); mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack); mIbtnBack.setOnClickListener(this); tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs); pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager); Intent intent = getIntent();//from w w w . ja va 2 s . co m //??1 2 ?? ???searchClassifyType mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1); adapter = new MyPagerAdapter(getSupportFragmentManager()); // ???N?? pager.setOffscreenPageLimit(adapter.getCount()); pager.setAdapter(adapter); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); pager.setCurrentItem(intent.getIntExtra("tabCode", 0)); tabs.setViewPager(pager); changeColor(currentColor); }
From source file:com.android.settings.localepicker.LocaleDragAndDropAdapter.java
public LocaleDragAndDropAdapter(Context context, List<LocaleStore.LocaleInfo> feedItemList) { this.mFeedItemList = feedItemList; this.mContext = context; final float dragElevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, context.getResources().getDisplayMetrics()); this.mItemTouchHelper = new ItemTouchHelper( new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0 /* no swipe */) { @Override/*from w w w . j a va2s . c om*/ public boolean onMove(RecyclerView view, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); return true; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { // Swipe is disabled, this is intentionally empty. } private static final int SELECTION_GAINED = 1; private static final int SELECTION_LOST = 0; private static final int SELECTION_UNCHANGED = -1; private int mSelectionStatus = SELECTION_UNCHANGED; @Override public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); // We change the elevation if selection changed if (mSelectionStatus != SELECTION_UNCHANGED) { viewHolder.itemView .setElevation(mSelectionStatus == SELECTION_GAINED ? dragElevation : 0); mSelectionStatus = SELECTION_UNCHANGED; } } @Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { super.onSelectedChanged(viewHolder, actionState); if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { mSelectionStatus = SELECTION_GAINED; } else if (actionState == ItemTouchHelper.ACTION_STATE_IDLE) { mSelectionStatus = SELECTION_LOST; } } }); }