Example usage for android.widget LinearLayout setOrientation

List of usage examples for android.widget LinearLayout setOrientation

Introduction

In this page you can find the example usage for android.widget LinearLayout setOrientation.

Prototype

public void setOrientation(@OrientationMode int orientation) 

Source Link

Document

Should the layout be a column or a row.

Usage

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private LinearLayout createContainerLayout(Context context) {
    LinearLayout container = new LinearLayout(context);
    container.setId(R.id.absQuizViewContainer);
    container.setOrientation(LinearLayout.VERTICAL);
    return container;
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

/**
 *
 * @return horizontal screen orientation
 *///from  w  ww .  ja v a2  s . co  m
public boolean createRootLayout(LinearLayout l) {
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        l.setPadding(toPixels(55), toPixels(4), toPixels(55), toPixels(4));
        return true;
    } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        l.setPadding(toPixels(4), toPixels(4), toPixels(4), toPixels(4));
    }
    return false;
}

From source file:org.mariotaku.twidere.fragment.support.BaseSupportListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from  w w  w. j  av a  2s .  c  o  m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context));
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:mobisocial.musubi.objects.WebAppObj.java

@Override
public View createView(Context context, ViewGroup parent) {
    LinearLayout frame = new LinearLayout(context);
    frame.setLayoutParams(CommonLayouts.FULL_WIDTH);
    frame.setOrientation(LinearLayout.VERTICAL);

    LinearLayout appBar = new LinearLayout(context);
    appBar.setLayoutParams(CommonLayouts.FULL_WIDTH);
    appBar.setOrientation(LinearLayout.HORIZONTAL);
    frame.addView(appBar);/*from www  .j a va  2 s. c o  m*/

    Drawable icon = context.getResources().getDrawable(R.drawable.ic_menu_globe);
    ImageView iv = new ImageView(context);
    iv.setImageDrawable(icon);
    iv.setAdjustViewBounds(true);
    iv.setMaxWidth(60);
    iv.setMaxHeight(60);
    iv.setLayoutParams(CommonLayouts.WRAPPED);
    appBar.addView(iv);

    TextView tv = new TextView(context);
    tv.setLayoutParams(CommonLayouts.WRAPPED);
    tv.setGravity(Gravity.CENTER_VERTICAL);
    appBar.addView(tv);

    LinearLayout actionBar = new LinearLayout(context);
    actionBar.setLayoutParams(CommonLayouts.WRAPPED);
    actionBar.setOrientation(LinearLayout.HORIZONTAL);
    frame.addView(actionBar);

    Button b = new Button(context);
    // required for listview long-press
    b.setLayoutParams(CommonLayouts.WRAPPED);
    b.setFocusable(false);
    b.setText("Run");
    b.setOnClickListener(getRunListener());
    actionBar.addView(b);

    b = new Button(context);
    // required for listview long-press
    b.setLayoutParams(CommonLayouts.WRAPPED);
    b.setFocusable(false);
    b.setOnClickListener(getAddListener());
    actionBar.addView(b);

    return frame;
}

From source file:org.xbmc.kore.ui.sections.audio.AlbumSongsListFragment.java

@Nullable
@Override/*w ww .  j  a  v  a 2  s.  co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    linearLayout.setLayoutParams(lp);
    return linearLayout;
}

From source file:com.sb.tododemo.widgets.SavedStateFragmentTabHost.java

private void initFragmentTabHost(final Context context, final AttributeSet attrs) {

    final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*from  w w  w.j  a v a 2s . com*/

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        final LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        final TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(LinearLayout.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:org.apache.cordova.SplashScreenInternal.java

/**
 * Shows the splash screen over the full Activity
 *///from w w w. j  a v  a2 s  .c  om
@SuppressWarnings("deprecation")
private void showSplashScreen(final boolean hideAfterDelay) {
    final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000);
    final int drawableId = preferences.getInteger("SplashDrawableId", 0);

    // If the splash dialog is showing don't try to show it again
    if (this.splashDialog != null && splashDialog.isShowing()) {
        return;
    }
    if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) {
        return;
    }

    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            // Get reference to display
            Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
            Context context = webView.getContext();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(context);
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);

            // TODO: Use the background color of the webview's parent instead of using the
            // preference.
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(drawableId);

            // Create and show the dialog
            splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((cordova.getActivity().getWindow().getAttributes().flags
                    & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            if (hideAfterDelay) {
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        removeSplashScreen();
                    }
                }, splashscreenTime);
            }
        }
    });
}

From source file:org.apache.cordova.AndroidChromeClient.java

@Override
/**/*from   w ww  .java2s . co m*/
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
    return mVideoProgressView;
}

From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);
    super.onCreate(savedInstanceState);

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    final String title;

    isModmail = getIntent() != null && getIntent().getBooleanExtra("modmail", false);

    if (!isModmail) {
        title = getString(R.string.mainmenu_inbox);
    } else {/*from www  .  ja v  a  2  s . com*/
        title = getString(R.string.mainmenu_modmail);
    }

    OptionsMenuUtility.fixActionBar(this, title);

    headerItems = PrefsUtility.appearance_comment_header_items(this, sharedPreferences);
    headerItems.remove(PrefsUtility.AppearanceCommentHeaderItems.SCORE);

    final LinearLayout outer = new LinearLayout(this);
    outer.setOrientation(android.widget.LinearLayout.VERTICAL);

    if (solidblack) {
        outer.setBackgroundColor(Color.BLACK);
    }

    loadingView = new LoadingView(this, getString(R.string.download_waiting), true, true);

    notifications = new LinearLayout(this);
    notifications.setOrientation(android.widget.LinearLayout.VERTICAL);
    notifications.addView(loadingView);

    final ListView lv = new ListView(this);

    lv.setSmoothScrollbarEnabled(false);
    lv.setVerticalFadingEdgeEnabled(false);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            final Object item = lv.getAdapter().getItem(position);

            if (item != null && item instanceof RedditPreparedInboxItem) {
                ((RedditPreparedInboxItem) item).handleInboxClick(InboxListingActivity.this);
            }
        }
    });

    adapter = new InboxListingAdapter(this, this);
    lv.setAdapter(adapter);

    registerForContextMenu(lv);

    outer.addView(notifications);
    outer.addView(lv);

    makeFirstRequest(this);

    setContentView(outer);
}

From source file:de.gebatzens.ggvertretungsplan.fragment.RemoteDataFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    if (GGApp.GG_APP.getDataForFragment(type) != null)
        createRootView(inflater, l);/*from  w w  w  .j  a  v  a2  s .  co m*/
    return l;
}