Java Code Examples for android.widget.LinearLayout.setTranslationX()

The following are Jave code examples for showing how to use setTranslationX() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Pocket-Plays-for-Twitch   File: StreamerInfoFragment.java   Source Code and License Vote up 6 votes
public void initColorandLayout(int color, int colorLight, int textColor, boolean inLandScape) {
    StreamerInfoName.setTextColor(textColor);
    StreamerInfoName.setBackgroundColor(colorLight);

    if(inLandScape){
        Log.v(LOG_TAG, "Is in landscape - Fragment");
        //StreamerInfoName.getLayoutParams().width = (int) (((getResources().getDisplayMetrics().widthPixels)/100) * StreamerInfoActivity.landscape_content_width - (context.getResources().getDimension(R.dimen.fragment_streamerInfo_cardElevation) * 2));
    } else {
        ContentLayout.setMaxCardElevation(0);
        ContentLayout.setCardElevation(0);
        int screenWidth = (getResources().getDisplayMetrics().widthPixels);
        LinearLayout llContainer = (LinearLayout) rootView.findViewById(R.id.fragment_streamerInfo_container_layout);

        int newWidth = (int)(screenWidth + getResources().getDimension(R.dimen.fragment_streamerInfo_cardElevation));
        llContainer.getLayoutParams().width = newWidth;

        float newTranslationX = (float)((newWidth - screenWidth) * -0.5);
        llContainer.setTranslationX(newTranslationX);
        llContainer.setGravity(Gravity.CENTER_HORIZONTAL);

    }
}