List of usage examples for android.view View setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentJournalMainHome.java
/** * DragTopLayout displays the nutrition information * Attached to ScrollView//from w ww. j ava 2 s .c o m * When the scrollView y coordinates equal 0, the pull down is enabled */ private void InitializeDragTopLayout() { final DragTopLayout mDragLayout = (DragTopLayout) v.findViewById(R.id.drag_layout); mDragLayout.setOverDrag(false); mDragLayout.toggleTopView(); mDragLayout.listener(this); final ScrollView mScrollView = (ScrollView) v.findViewById(R.id.scrollView); mScrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mDragLayout.setTouchMode(AttachUtil.isScrollViewAttach(mScrollView)); return false; } }); mCaloriePullDownView = (LinearLayout) v.findViewById(R.id.view4); Equations.dpToPx(getActivity(), 100); pullDownItems = (LinearLayout) v.findViewById(R.id.pullDownIems); mCalories = (TextView) v.findViewById(R.id.txtCalories); mCaloriesRemainder = (TextView) v.findViewById(R.id.txtRemainderCalories); mCalories.setTextSize(0); mCaloriesRemainder.setTextSize(0); View v1 = v.findViewById(R.id.view1); View v2 = v.findViewById(R.id.view2); View v3 = v.findViewById(R.id.view3); slide_down_padding = Math.round(Equations.dpToPx(getActivity(), 90)); v1.setPadding(slide_down_padding, 0, slide_down_padding, 0); v2.setPadding(slide_down_padding, 0, slide_down_padding, 0); v3.setPadding(slide_down_padding, 0, slide_down_padding, 0); }
From source file:com.hua.weget.PagerSlidingTabStrip.java
@SuppressLint("NewApi") private void addTab(final int position, View tab) { tab.setFocusable(true);//from ww w. j a v a 2 s. c o m // ((TextView)(tab)).setCompoundDrawablesRelativeWithIntrinsicBounds( // // context.getResources().getDrawable(mDrawableIds[position]), null, null, null); ((TextView) (tab)).setCompoundDrawablesWithIntrinsicBounds( context.getResources().getDrawable(mDrawableIds[position]), null, null, null); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:org.live.circle.component.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);//from ww w. j av a 2s .c o m tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (currentPosition == position) { if (onTabSelectedListener != null) { onTabSelectedListener.onTabReselected(v, position); } } else { if (onTabSelectedListener != null) { onTabSelectedListener.onTabSelected(v, position); } pager.setCurrentItem(position); } } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:ru.for_inform.we_recommend.view.Loading_Activity.java
private void setPaddings(View view, int left, int top, int right, int bottom) { float density = context.getResources().getDisplayMetrics().density; int paddingLeft = (int) (left * density); int paddingTop = (int) (top * density); int paddingRight = (int) (right * density); int paddingBottom = (int) (bottom * density); view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); }
From source file:com.android.view.ScrollView.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/*from w w w. ja v a 2s . c om*/ tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (jumps == null || jumps.size() == 0) { pager.setCurrentItem(position); //myBack.back(position); } else { if (jumps.contains(position)) { pager.setCurrentItem(position); //myBack.back(position); } else { //myBack.back(position); } } } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void initialiseNarrativesView() { mScanningForNarratives = false;/*from w ww . ja v a2s . c om*/ mNarratives = (NarrativesListView) findViewById(R.id.list_narratives); // for API 11 and above, buttons are in the action bar if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { LayoutInflater layoutInflater = getLayoutInflater(); View headerRow = layoutInflater.inflate(R.layout.narratives_header, null, false); mNarratives.addHeaderView(headerRow, null, false); // false = not selectable View emptyView = layoutInflater.inflate(R.layout.narratives_empty, null, false); ((ViewGroup) mNarratives.getParent()).addView(emptyView); mNarratives.setEmptyView(emptyView); // must add separately as the header isn't shown when empty } else { // initial empty list placeholder - add manually as the < v11 version includes the header row TextView emptyView = new TextView(NarrativeBrowserActivity.this); emptyView.setGravity(Gravity.CENTER | Gravity.TOP); emptyView.setPadding(10, getResources().getDimensionPixelSize(R.dimen.narrative_list_empty_hint_top_padding), 10, 10); // temporary emptyView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); emptyView.setText(getString(R.string.narrative_list_empty)); ((ViewGroup) mNarratives.getParent()).addView(emptyView); mNarratives.setEmptyView(emptyView); } // originally used to fix selection highlights when using hardware button to select // now done by overriding isEnabled in NarrativeAdapter // mNarratives.setFocusable(false); // mNarratives.setFocusableInTouchMode(false); mNarrativeAdapter = new NarrativeAdapter(this, true, false); mNarratives.setAdapter(mNarrativeAdapter); getSupportLoaderManager().initLoader(R.id.loader_narratives_completed, null, this); mNarratives.setOnScrollListener(new ScrollManager()); mNarratives.setOnTouchListener(new FingerTracker()); mNarratives.setOnItemSelectedListener(new SelectionTracker()); mNarratives.setOnItemClickListener(new NarrativeViewer()); mPopupPosition = getLayoutInflater().inflate(R.layout.popup_position, null); mPopupText = (TextView) mPopupPosition.findViewById(R.id.popup_text); }
From source file:io.jari.geenstijl.Blog.java
public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.blog);/*from www. j a v a 2 s . c o m*/ super.onCreate(savedInstanceState); actionBar = getSupportActionBar(); final PullToRefreshLayout mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout); View drawer = findViewById(R.id.left_drawer); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerStateChanged(int newState) { super.onDrawerStateChanged(newState); enableImmersive(false, drawerLayout); } }; drawerLayout.setDrawerListener(drawerToggle); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); if (Build.VERSION.SDK_INT >= 19) { SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); drawer.setPadding(drawer.getPaddingLeft(), drawer.getPaddingTop() + config.getPixelInsetTop(true), drawer.getPaddingRight(), drawer.getPaddingBottom()); } ListView siteSwitch = (ListView) drawer.findViewById(R.id.site_switcher); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] { "GeenStijl.nl", "GeenStijl.tv" }); siteSwitch.setAdapter(arrayAdapter); siteSwitch.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: API.setDomain("www.geenstijl.nl", Blog.this); break; case 1: API.setDomain("www.geenstijl.tv", Blog.this); break; } forceNoImmersive = true; enableImmersive(false, drawerLayout); drawerLayout.closeDrawers(); mPullToRefreshLayout.setRefreshing(true); new Thread(new Runnable() { public void run() { forceNoImmersive = true; try { final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext()); initUI(artikelen, false); runOnUiThread(new Runnable() { public void run() { mPullToRefreshLayout.setRefreshComplete(); forceNoImmersive = false; } }); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { forceNoImmersive = false; mPullToRefreshLayout.setRefreshComplete(); Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout" : e.getLocalizedMessage(), Style.ALERT).show(); } }); } } }).start(); } }); ListView applist = (ListView) findViewById(R.id.applist); applist.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] { getResources().getString(R.string.options), getResources().getString(R.string.about) })); applist.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: startActivity(new Intent(Intent.ACTION_VIEW, null, Blog.this, Settings.class)); break; case 1: new AboutDialog(Blog.this).show(getSupportFragmentManager(), "AbtDlg"); break; } drawerLayout.closeDrawers(); } }); reloadDrawer(); // Now setup the PullToRefreshLayout ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(new OnRefreshListener() { public void onRefreshStarted(View view) { new Thread(new Runnable() { public void run() { forceNoImmersive = true; try { final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext()); initUI(artikelen, false); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { forceNoImmersive = false; mPullToRefreshLayout.setRefreshComplete(); Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout" : e.getLocalizedMessage(), Style.ALERT).show(); } }); } } }).start(); } }).setup(mPullToRefreshLayout); new Thread(new Runnable() { public void run() { try { final Artikel[] artikelen = API.getArticles(false, false, getApplicationContext()); initUI(artikelen, true); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { errorMessage = e.getMessage(); switchState(STATE_ERROR); } }); } } }).start(); //do changelog stuff SharedPreferences sPref = this.getSharedPreferences("geenstijl", 0); int version = 0; try { version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException ignored) { } //is changelog already read if (!sPref.getBoolean("changelog-" + version, false)) { //set changelog to read sPref.edit().putBoolean("changelog-" + version, true).commit(); //show dialog LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.changelog, null); new AlertDialog.Builder(this).setTitle(R.string.changelog_title).setView(chgList) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create().show(); } }
From source file:com.shuyu.apprecycler.view.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/*from w w w . j a v a 2 s. c o m*/ if (tabClickable) { tab.setOnClickListener(new OnClickListener() { public static final int MIN_CLICK_DELAY_TIME = 1000; private long lastClickTime = 0; @Override public void onClick(View v) { pager.setCurrentItem(position); long currentTime = Calendar.getInstance().getTimeInMillis(); if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) { lastClickTime = currentTime; } else { } } }); } tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.brq.wallet.activity.modern.AccountsFragment.java
private View createSeparator() { View v = new View(getActivity()); v.setLayoutParams(_separatorLayoutParameters); v.setBackgroundColor(_separatorColor); v.setPadding(10, 0, 10, 0); return v;/*www. j ava2s . co m*/ }
From source file:com.shome.app.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { if (useToggleTab) { tab.setOnClickListener(new OnClickListener() { @Override//w ww . j a va 2 s . c o m public void onClick(View v) { pager.setCurrentItem(position); ToggleButton tb = (ToggleButton) v; toggleTabIfUsingToggleTabProvider(tb); } }); } else { tab.setFocusable(true); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); } if (shouldSetPadding) { tab.setPadding(tabPadding, 0, tabPadding, 0); } tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }