List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.byteridge.bookcircle.ui.TabPageIndicator.java
public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); ctx = context;/*from ww w . j av a2 s. c om*/ setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(getContext()); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, FILL_PARENT)); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from w w w . j a va 2 s . c om*/ LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:com.fuav.android.view.viewPager.TabPageIndicator.java
public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPageIndicator); mTextSize = a.getDimension(R.styleable.TabPageIndicator_android_textSize, 15f); a.recycle();/* w w w . ja v a2 s .c o m*/ setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(getContext()); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
From source file:com.renren.api.connect.android.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext()); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("Loading..."); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();/*from w ww .j ava2 s .co m*/ } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.iStudy.Study.Renren.View.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext()); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("Loading..."); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();/*w w w. ja va 2 s . c om*/ } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; @SuppressWarnings("deprecation") float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.ztspeech.weibo.sdk.renren.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext(), R.style.mydialog); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("..."); progress.setCanceledOnTouchOutside(false); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();//w w w . java 2 s. c o m } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:au.com.wallaceit.reddinator.TabCommentsFragment.java
@SuppressLint({ "SetJavaScriptEnabled", "AddJavascriptInterface" }) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this.getActivity(); SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); global = (GlobalObjects) mContext.getApplicationContext(); final boolean load = getArguments().getBoolean("load"); // get needed activity values articleId = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_ID); permalink = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK); ll = new LinearLayout(mContext); ll.setLayoutParams(new WebView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0)); // fixes for webview not taking keyboard input on some devices mWebView = new WebView(mContext); mWebView.setLayoutParams(new WebView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0)); ll.addView(mWebView);/*from ww w. j a v a 2 s . c o m*/ WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); // enable ecmascript webSettings.setDomStorageEnabled(true); // some video sites require dom storage webSettings.setSupportZoom(false); webSettings.setBuiltInZoomControls(false); webSettings.setDisplayZoomControls(false); int fontSize = Integer.parseInt(mSharedPreferences.getString("commentfontpref", "18")); webSettings.setDefaultFontSize(fontSize); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); mSharedPreferences.getString("titlefontpref", "16"); final String themeStr = global.mThemeManager.getActiveTheme("appthemepref").getValuesString(); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { boolean redditLink = false; System.out.println(url); if (url.indexOf("file://") == 0) { // fix for short sub and user links url = url.replace("file://", "https://www.reddit.com") + "/.compact"; redditLink = true; } if (redditLink || url.indexOf("https://www.reddit.com/") == 0) { Intent i = new Intent(mContext, WebViewActivity.class); i.putExtra("url", url); startActivity(i); } else { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); } return true; // always override url } public void onPageFinished(WebView view, String url) { mWebView.loadUrl("javascript:init(\"" + StringEscapeUtils.escapeJavaScript(themeStr) + "\", \"" + global.mRedditData.getUsername() + "\")"); if (load) load(); } }); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.requestFocus(View.FOCUS_DOWN); WebInterface webInterface = new WebInterface(mContext); mWebView.addJavascriptInterface(webInterface, "Reddinator"); mWebView.loadUrl("file:///android_asset/comments.html#" + articleId); }
From source file:BannerListView.java
/** * this method take supported fragment and fragment activity to add that * fragment as a banner to listView it create a layout at runtime then when * view is added to list we replace it with fragment otherwise it will crash * since view is not on screen to be replaced * /*from ww w. j av a 2 s.c o m*/ * @param fragment * @param activity */ public void addBannerFragment(final Fragment fragment, final FragmentActivity activity) { LinearLayout layout = new LinearLayout(activity); AbsListView.LayoutParams param = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layout.setLayoutParams(param); layout.setId(CONTAINER_ID); addLayoutContainer(layout); this.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { BannerListView.this.removeOnLayoutChangeListener(this); FragmentManager manager = activity.getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(CONTAINER_ID, fragment).commit(); } }); }
From source file:com.weizoo.game.go.HappyGo.HappyGo.java
private void initAd() { try {//from w w w. j a va 2s .c om LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // Create the adView. adView = new AdView(this, AdSize.SMART_BANNER, "a152c6a39379a40"); // Add the adView to it. layout.addView(adView); // Initiate a generic request. AdRequest adRequest = new AdRequest(); adRequest.addTestDevice("355296050198170"); // Load the adView with the ad request. adView.loadAd(adRequest); } catch (Exception e) { e.printStackTrace(); } }
From source file:bigshots.people_helping_people.scroll_iew_lib.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*w w w. ja va2s . co m*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(0, tabTextSize); tabTextColor = a.getColor(1, tabTextColor); a.recycle(); // get custom attrs indicatorColor = getResources().getColor(R.color.current_charity_color); underlineColor = indicatorColor; dividerColor = 0xffffffff; tabBackgroundResId = 0x00000000; rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }