Java Code Examples for android.widget.LinearLayout#getParent()

The following examples show how to use android.widget.LinearLayout#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListenerHelper.java    From Vidsta with GNU General Public License v3.0 5 votes vote down vote up
static void createListenerLog(LinearLayout messagesContainer, String text) {
    String currentDateTime = new SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
    TextView textView = new TextView(messagesContainer.getContext());
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(14);
    textView.setText(currentDateTime + ": " + text);

    messagesContainer.addView(textView);
    final ScrollView scrollView = (ScrollView)messagesContainer.getParent();
    scrollView.post(new Runnable() {
        public void run() {
            scrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}
 
Example 2
Source File: ViewUtils.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Procedure returns the layout depth of this term related to mainView
 */
public static int getLayoutDepth(LinearLayout l)
{
    int retValue = 0;
    if (l == null)
    {
        return retValue;
    }
    ViewParent p = l.getParent();
    while (p != null)
    {
        if (p instanceof TwoDScrollView)
        {
            if (((TwoDScrollView) p).getId() == R.id.main_scroll_view)
            {
                break;
            }
        }
        if (p instanceof FormulaBase && p.getParent() == null)
        {
            retValue += 2;
            break;
        }
        retValue++;
        p = p.getParent();
    }
    return retValue;
}
 
Example 3
Source File: BaseActivity.java    From android-lite-async with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_list_btn);
    TAG = this.getClass().getSimpleName();
    Log.setTag(TAG);

    container = (LinearLayout) findViewById(R.id.container);
    scroll = (ScrollView) container.getParent();
    TextView tv = (TextView) container.findViewById(R.id.title);
    tv.setText(getMainTitle());
    mTvSubTitle = (TextView) container.findViewById(R.id.sub_title);

    String[] bttxt = getButtonTexts();
    if (bttxt != null) {
        for (int i = 0; i < bttxt.length; i++) {
            Button bt = new Button(this);
            LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            int margin = getResources().getDimensionPixelSize(R.dimen.common_marin);
            lp.setMargins(margin, margin, margin, margin);
            bt.setId(i);
            bt.setText(bttxt[i]);
            bt.setOnClickListener(this);
            bt.setLayoutParams(lp);
            container.addView(bt);
        }
    }
}
 
Example 4
Source File: BaseActivity.java    From android-lite-orm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_list_btn);
    TAG = this.getClass().getSimpleName();
    OrmLog.setTag(TAG);

    container = (LinearLayout) findViewById(R.id.container);
    scroll = (ScrollView) container.getParent();
    TextView tv = (TextView) container.findViewById(R.id.title);
    tv.setText(getMainTitle());
    mTvSubTitle = (TextView) container.findViewById(R.id.sub_title);

    String[] bttxt = getButtonTexts();
    if (bttxt != null) {
        for (int i = 0; i < bttxt.length; i++) {
            Button bt = new Button(this);
            LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            int margin = getResources().getDimensionPixelSize(R.dimen.common_marin);
            lp.setMargins(margin, margin, margin, margin);
            bt.setId(i);
            bt.setText(bttxt[i]);
            bt.setOnClickListener(this);
            bt.setLayoutParams(lp);
            container.addView(bt);
        }
    }
}
 
Example 5
Source File: AbstractMessage.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@CallSuper
protected void updateLayoutForReceive(VH holder) {
    ViewGroup frameLayout = (ViewGroup) holder.itemView.findViewById(R.id.mainContainer);
    ImageView imgTick = (ImageView) holder.itemView.findViewById(R.id.cslr_txt_tic);
    TextView messageText = (TextView) holder.itemView.findViewById(R.id.messageSenderTextMessage);

    LinearLayout root = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer);
    LinearLayout timeLayout = (LinearLayout) root.getParent();
    timeLayout.setGravity(Gravity.LEFT);

    if (messageText != null) {
        messageText.setTextColor(Color.parseColor(G.textBubble));
    }
    //   ProtoGlobal.RoomMessageType messageType = mMessage.forwardedFrom == null ? mMessage.messageType : mMessage.forwardedFrom.getMessageType();

    if (G.isDarkTheme) {
        setTextColor(imgTick, R.color.white);
    } else {
        setTextColor(imgTick, R.color.colorOldBlack);
    }


    ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).gravity = Gravity.LEFT;

    ((LinearLayout.LayoutParams) root.getLayoutParams()).gravity = Gravity.LEFT;

    if (G.isDarkTheme) {
        ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangel_white_round_dark);
    } else {
        ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangel_white_round);
    }

    /**
     * add main layout margin to prevent getting match parent completely
     * set to mainContainer not itemView because of selecting item foreground
     */

    GradientDrawable circleDarkColor = (GradientDrawable) ((View) root.getParent()).getBackground();
    circleDarkColor.setColor(Color.parseColor(G.bubbleChatReceive));

    ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).leftMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp10);
    ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).rightMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp28);
}
 
Example 6
Source File: AbstractMessage.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@CallSuper
    protected void updateLayoutForSend(VH holder) {

        ViewGroup frameLayout = (ViewGroup) holder.itemView.findViewById(R.id.mainContainer);
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).gravity = Gravity.RIGHT;
        LinearLayout root = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer);

        ((LinearLayout.LayoutParams) root.getLayoutParams()).gravity = Gravity.RIGHT;

        LinearLayout timeLayout = (LinearLayout) root.getParent();
        timeLayout.setGravity(Gravity.RIGHT);

        ImageView imgTick = (ImageView) holder.itemView.findViewById(R.id.cslr_txt_tic);
        TextView messageText = (TextView) holder.itemView.findViewById(R.id.messageSenderTextMessage);
        //  TextView iconHearing = (TextView) holder.itemView.findViewById(R.id.cslr_txt_hearing);

        if (messageText != null) {
            messageText.setTextColor(Color.parseColor(G.textBubble));
        }
        //   ProtoGlobal.RoomMessageType messageType = mMessage.forwardedFrom == null ? mMessage.messageType : mMessage.forwardedFrom.getMessageType();


        ProtoGlobal.RoomMessageStatus status = ProtoGlobal.RoomMessageStatus.UNRECOGNIZED;
        if (mMessage.status != null) {
            try {
                status = ProtoGlobal.RoomMessageStatus.valueOf(mMessage.status);
            } catch (RuntimeException e) {
                e.printStackTrace();
            }
        }

        if (status == ProtoGlobal.RoomMessageStatus.SEEN) {
            if (G.isDarkTheme) {
                setTextColor(imgTick, R.color.iGapColor);
            } else {
                setTextColor(imgTick, R.color.backgroundColorCall2);
            }

        } else if (status == ProtoGlobal.RoomMessageStatus.LISTENED) {
            // iconHearing.setVisibility(View.VISIBLE);
            if (G.isDarkTheme) {
                setTextColor(imgTick, R.color.iGapColor);
            } else {
                setTextColor(imgTick, R.color.backgroundColorCall2);
            }

            imgTick.setVisibility(View.VISIBLE);
        } else {
//            setTextColor(imgTick, Color.parseColor(G.txtIconCheck));
            imgTick.setColorFilter(Color.parseColor(G.txtIconCheck));
        }


        if (G.isDarkTheme) {
            ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color_dark);
        } else {
            ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color);
        }
        GradientDrawable circleDarkColor = (GradientDrawable) ((View) root.getParent()).getBackground();
        circleDarkColor.setColor(Color.parseColor(G.bubbleChatSend));

        /**
         * add main layout margin to prevent getting match parent completely
         * set to mainContainer not itemView because of selecting item foreground
         */
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).leftMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp28);
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).rightMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp10);

        //((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).rightMargin = (int) holder.itemView.getResources().getDimension(R.dimen.messageBox_minusLeftRightMargin);
        //((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).leftMargin = 0;
    }
 
Example 7
Source File: TaskbarControllerTest.java    From Taskbar with Apache License 2.0 4 votes vote down vote up
@Test
public void testDrawSysTrayParentLayoutVisibility() {
    LinearLayout sysTrayLayout = initializeSysTrayLayout(POSITION_BOTTOM_RIGHT);
    ViewGroup parent = (ViewGroup) sysTrayLayout.getParent();
    assertEquals(View.VISIBLE, parent.getVisibility());
}