Example usage for android.widget RelativeLayout ALIGN_PARENT_BOTTOM

List of usage examples for android.widget RelativeLayout ALIGN_PARENT_BOTTOM

Introduction

In this page you can find the example usage for android.widget RelativeLayout ALIGN_PARENT_BOTTOM.

Prototype

int ALIGN_PARENT_BOTTOM

To view the source code for android.widget RelativeLayout ALIGN_PARENT_BOTTOM.

Click Source Link

Document

Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge.

Usage

From source file:cn.org.eshow.framwork.activity.AbActivity.java

/**
 * ??./*from  www.j  ava2  s .c  om*/
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new AbTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new AbBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AbActivityManager.getInstance().addActivity(this);
}

From source file:com.antew.redditinpictures.ui.RedditImageListFragmentFree.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout v = (RelativeLayout) super.onCreateView(inflater, container, savedInstanceState);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mHideAds,
            new IntentFilter(ConstsFree.REMOVE_ADS));
    /**/*from  w  w w . j ava 2s .co m*/
     * If ads are disabled we don't need to load any
     */
    if (!SharedPreferencesHelperFree.getDisableAds(getActivity())) {
        mAdView = new AdView(getActivity(), AdSize.SMART_BANNER, ConstsFree.ADMOB_ID);

        /**
         * The AdView should be attached to the bottom of the screen, with the GridView position above it
         */
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        v.addView(mAdView, adParams);

        mAdView.loadAd(AdUtil.getAdRequest());
    }

    return v;
}

From source file:com.antew.redditinpictures.ui.RedditImageGridFragmentFree.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout v = (RelativeLayout) super.onCreateView(inflater, container, savedInstanceState);
    mGridView = (GridView) v.findViewById(R.id.gridView);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mHideAds,
            new IntentFilter(ConstsFree.REMOVE_ADS));
    /**//from   ww  w .  j  a  v  a2  s. co  m
     * If ads are disabled we don't need to load any
     */
    if (!SharedPreferencesHelperFree.getDisableAds(getActivity())) {
        mAdView = new AdView(getActivity(), AdSize.SMART_BANNER, ConstsFree.ADMOB_ID);

        /**
         * The AdView should be attached to the bottom of the screen, with the GridView position above it
         */
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        v.addView(mAdView, adParams);

        /**
         * We use the onGlobalLayoutListener here in order to adjust the bottom margin of the GridView
         * so that when the user scrolls to the bottom of the GridView the last images are not obscured
         * by the AdView
         */
        mAdView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                if (mAdView != null && mGridView != null) {
                    int height = mAdView.getHeight();
                    if (height > 0) {
                        RelativeLayout.LayoutParams gridViewParams = (RelativeLayout.LayoutParams) mGridView
                                .getLayoutParams();
                        gridViewParams.setMargins(0, 0, 0, height);
                        mGridView.setLayoutParams(gridViewParams);
                        mAdView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }
            }
        });
        mAdView.loadAd(AdUtil.getAdRequest());
    }

    return v;
}

From source file:org.orange.querysystem.content.TabsAdapter.java

private void setTabForIfLowerThanHONEYCOMB() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        View child = mTabHost.getTabWidget().getChildAt(getCount() - 1);
        child.setBackgroundColor(0xFFB5E61D);
        TextView tv = (TextView) child.findViewById(android.R.id.title);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //??  
        params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); //?  
        params.setMargins(dp2px(10), dp2px(4), dp2px(10), dp2px(4));
        child.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT;
    }//from w w w .j  a v a  2s . c o m
}

From source file:com.androidhiddencamera.HiddenCameraFragment.java

/**
 * Add camera preview to the root of the activity layout.
 *
 * @return {@link CameraPreview} that was added to the view.
 *//*from  w w  w.j a v  a2 s  .  co m*/
private CameraPreview addPreView() {
    //create fake camera view
    CameraPreview cameraSourceCameraPreview = new CameraPreview(getActivity(), this);
    cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    View view = ((ViewGroup) getActivity().getWindow().getDecorView().getRootView()).getChildAt(0);

    if (view instanceof LinearLayout) {
        LinearLayout linearLayout = (LinearLayout) view;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1);
        linearLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof RelativeLayout) {
        RelativeLayout relativeLayout = (RelativeLayout) view;

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        relativeLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) view;

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1);
        frameLayout.addView(cameraSourceCameraPreview, params);
    } else {
        throw new RuntimeException("Root view of the activity/fragment cannot be frame layout");
    }

    return cameraSourceCameraPreview;
}

From source file:com.androidhiddencamera.HiddenCameraActivity.java

/**
 * Add camera preview to the root of the activity layout.
 *
 * @return {@link CameraPreview} that was added to the view.
 *//*  w w  w.  j a v  a  2  s.  c o m*/
private CameraPreview addPreView() {
    //create fake camera view
    CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this);
    cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    View view = ((ViewGroup) getWindow().getDecorView().getRootView()).getChildAt(0);

    if (view instanceof LinearLayout) {
        LinearLayout linearLayout = (LinearLayout) view;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1);
        linearLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof RelativeLayout) {
        RelativeLayout relativeLayout = (RelativeLayout) view;

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        relativeLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) view;

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1);
        frameLayout.addView(cameraSourceCameraPreview, params);
    } else {
        throw new RuntimeException("Root view of the activity/fragment cannot be frame layout");
    }

    return cameraSourceCameraPreview;
}

From source file:com.ohso.omgubuntu.BaseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Reset the default action bar since it's global and setActionBar() would otherwise change things permanently
    dataSource = new ArticleDataSource(getActivity());
    actionBar = ((BaseActivity) getActivity()).getSupportActionBar();
    ((BaseActivity) getActivity()).getDefaultActionBar();
    setActionBar();/*w  w  w  .j  ava 2s  . c  om*/

    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.fragment_base_view, null, false);

    footerView = (TextView) inflater.inflate(R.layout.activity_main_footer, container, false);
    footerView.setVisibility(TextView.GONE);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    footerView.setLayoutParams(params);
    layout.addView(footerView);
    footerView.setOnClickListener(this);

    int columnNumber = getColumnByScreenSize();
    adapter = new ArticleAdapter(getActivity(), R.layout.article_row, R.id.article_row_text_title,
            new Articles(), columnNumber, footerView);
    imageHandler = ((BaseActivity) getActivity()).getImageHandler();
    adapter.setImageHandler(imageHandler);

    gridView = (GridView) layout.findViewById(R.id.fragment_base_gridview);
    gridView.setAdapter(adapter);
    gridView.setNumColumns(columnNumber);
    gridView.setScrollContainer(false);
    gridView.setOnTouchListener(this);
    gridView.setOnScrollListener(this);
    gridView.setOnItemClickListener(this);
    registerForContextMenu(gridView);

    getData();
    if (adapter.isEmpty()
            || (onStartRefresh == true && getActivity().getSharedPreferences(OMGUbuntuApplication.PREFS_FILE, 0)
                    .getBoolean(SettingsFragment.STARTUP_CHECK_ENABLED, true))) {
        onStartRefresh = false;
        setRefreshing();
    }

    if (adapter.getCount() >= ArticleDataSource.MAX_ARTICLES_PER_PAGE && footerEnabled) {
        adapter.setFooterEnabled(true);
    }

    return layout;
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingPlayView.java

/**
 * ???View.//from ww  w.ja v  a 2 s .  c  o m
 *
 * @param context the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new ESInnerViewPager(context);
    //ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    //
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new ESViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingPlayView.java

/**
 * ???View.//from  w ww . j  a  v  a2  s  . c o  m
 *
 * @param context the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    //ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    //
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:net.pocketmagic.android.carousel.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //no keyboard unless requested by user
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // compute screen size and scaling
    Singleton.getInstance().InitGUIFrame(this);

    int padding = m_Inst.Scale(10);
    // create the interface : full screen container
    RelativeLayout panel = new RelativeLayout(this);
    panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    panel.setPadding(padding, padding, padding, padding);
    panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
            new int[] { Color.WHITE, Color.GRAY }));
    setContentView(panel);// ww  w .  j  a v  a  2  s .c  om

    // copy images from assets to sdcard
    AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false);
    AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false);
    AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false);
    AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false);

    //Create carousel view documents
    ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>();
    for (int i = 0; i < 1000; i++) {
        CarouselDataItem docu;
        if (i % 4 == 0)
            docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image " + i);
        else if (i % 4 == 1)
            docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image " + i);
        else if (i % 4 == 2)
            docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image " + i);
        else
            docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image " + i);
        Docus.add(docu);
    }

    // add the serach filter
    EditText etSearch = new EditText(this);
    etSearch.setHint("Search your documents");
    etSearch.setSingleLine();
    etSearch.setTextColor(Color.BLACK);
    etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0);
    AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] {
            new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_TOP } }, -1,
            -1);
    etSearch.addTextChangedListener((TextWatcher) this);

    // add logo
    TextView tv = new TextView(this);
    tv.setTextColor(Color.BLACK);
    tv.setText("www.pocketmagic.net");
    AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] {
            new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_BOTTOM } },
            -1, -1);

    // create the carousel
    CarouselView coverFlow = new CarouselView(this);

    // create adapter and specify device independent items size (scaling)
    // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/
    m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300));
    coverFlow.setAdapter(m_carouselAdapter);
    coverFlow.setSpacing(-1 * m_Inst.Scale(150));
    coverFlow.setSelection(Integer.MAX_VALUE / 2, true);
    coverFlow.setAnimationDuration(1000);
    coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this);

    AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
            new int[][] { new int[] { RelativeLayout.CENTER_IN_PARENT } }, -1, -1);
}